Random Web and PHP Notes

Geek Interview Questions:

  • What will this do:
    <input type="submit" name="confirm" 
    id="confirm" value="Confirm Request"
    onclick="return confirm('Really Confirm Request?');">
  • Explain what JSON is…
  • Have you ever created or consumed web services in PHP?
  • Explain what REST is…
  • What does & do, eg:
    foreach($cust as &$c){

    function foo(&$bar){
    $bar = 'moo';
  • How can you use: $x++%2 eg: echo ($x++%2)?’Yes’:’No’;
  • What are the function arguments for the mail() command
  • What is memcached, have you used it?
  • Have you ever done pagination, explain quickly how to paginate a large mysql result.
  • What database abstraction classes have you used before.
  • Have you used firebug?
  • Write this another way:
  • What does this display?
    preg_match("/^(http://info@)?([^/]+)/i","http://info@abc.com", $data); 
    echo $data[2];
  • What will a print_r($_REQUEST); show on these form elements:
    <input type="checkbox" name="box[a]" value=yes> 
    <input type="checkbox" name="box[b]" value=yes>
  • What does this print out:
    $v=2; echo $v++%2;
  • Do you use <th>’s when writing html?
  • Explain what ob_start() does in PHP
  • Explain what is wrong with the following JavaScript, if ther is nothing wrong with it, then tell me what it will output:
    var moo = {
    foo: function(){
    var b = this.a--;
    a: 4
  • In what way are the JavaScript and Java programming languages related?
  • Explain what a fork bomb is
  • Is this valid JavaScript:
    var moo = {a : "string", b: 4, c: function(){ alert('moo'); } };
  • Do you know what the “short_open_tag” does in php.ini
  • What does set_time_limit(0); do in PHP?
  • Tell me what the parameter list of the mail() function is.
  • Show me how to send a HTML email using the PHP mail() function
  • How do you catch an exception in PHP?
  • What does json_decode() do in PHP?
  • How do you post data to a script via ajax using jQuery?
  • Using jQuery, what do you write in the onclick=”” event to hide and show the div?
    <a href="#" onclick="">Hide/Show Div</a>
    <div id="thediv">
    some random content
  • What does this command do: ssh -g -L 8080: foo@otherhost -P 2222
  • What does this command do: xhost +
  • Explain what the suphp apache module does?
  • What are the apache2 commands to enable a site called “foo”, it’s valid configuration files is /etc/apache2/sites-available/foo
  • Why problems does this cause in Internet Explorer:
    <input type="submit" name="upload" value="Click to upload" 
    onclick="this.disabled=true; this.value='Uploading...';">
  • more to come


PHP Stuff:

echo “123”; will print out a capital “S” – the octec value for S is 123.

when posting files from a form, use <form action=”foo.php” method=”post” enctype=”multipart/form-data”> without the enctype the file will not be sent to the server

when storing data in sessions: if there is a session key called $_SESSION[‘products’] and you use $products somewhere in your scripts for a different reason eg: $products=query(“SELECT * FROM…); on some PHP configurations $products and $_SESSION[‘products’] will be the same, so be careful with session key names. you could end up inadvertently messing with session values

if you have an input element <input type=”checkbox” name=”foo[123]” value=”Bar”> PHP will convert foo[123] into an array for you automatically. You can access this like: $foo = $_POST[‘foo’]; echo $foo[“123”]; // this prints Bar

after submitting a form (lets say a sign up form) it is always best to redirect the user to a separate “thank you” page instead of simply displaying a thankyou message at the end of the sign up script. this means if a user refreshes the “thank you” page, it will not sign them up again / throw a nasty re-post warning message in the browser.


same as:

<? if($foo) echo $bar; else echo $moo; ?>


<input type="checkbox" name="box[a]" value=yes>
<input type="checkbox" name="box[b]" value=yes>
<input type="checkbox" name="box[c]" value=yes>
<input type="checkbox" name="box[d]" value=yes>


?> <tr bgcolor="<?=($v %2)?'red':'green';?>"><td>fasdf</td></tr> <?
preg_match("/^(http://info@)?([^/] )/i","http://info@abc.com", $data);
echo $data[2];



  1. whats a <th> used for
  2. how do you create a horizontal css menu using <ul> and <li>



var moo = {
foo: function(){
var b = this.a--;
a: 4
// above alerts 2

var moo = {a : "string", b: 4, c: function(){ alert('moo'); } };


Leave a Reply

Your email address will not be published.