Skip to content

Instantly share code, notes, and snippets.

@MartinReidy
MartinReidy / webworkers.html
Created November 8, 2015 18:44 — forked from iwek/webworkers.html
Super Simple HTML5 Web Workers Example
<!--HTML file-->
<!DOCTYPE html>
<script>
//define a worker
var worker = new Worker('worker.js');
worker.addEventListener('message', function(e) {
console.log('Worker said: ', e.data);
}, false);
@MartinReidy
MartinReidy / ExemplarResponse.md
Last active August 8, 2019 20:50
Rebilly PHP Developer Coding Exemplar

Question 1

The excption that occurs when the string "Superman is awesome!" is used occurs because strpos return a postion index of 0 when the 'needle' string starts at the first character in the 'haystack' string. Php will evaluate !0 as false. So what happens in the case of "Superman is awesome!" is php eveluates '(!strpos(strtolower($str), 'superman'))' as true triggering the exception.

The way to correct this is to explicitly check for the return valsue of strpos to see if it is the booloean value false. This will distquising the cases of strpos returning the boolean fasle and the interger 0 when evaluated by the if statement

Replace

if(!strpos(strtolower($str), 'superman')) {