|
1.Is it possible to set a time expire page in PHP.? Yes it is Using header("Expires: fri, 07 mar 2007 05:00:00 GMT"); <?php header("Expires: fri, 07 mar 2007 05:00:00 GMT"); ?> 2.How can we SAVE an image from a remote web Server to my web server using PHP? <?php $file_rimg = fopen("http://w3answers /image23.jpg",'rb'); $newfile_name_img = "/tmp/tutorial.file"; $file_wnew = fopen($newfile_name_img,'wb'); while (!feof($file_rimg)) { $chunk_rd = fread($file_rimg,1024); fwrite($file_wnew,$chunk_rd); } fclose($file_wnew); fclose(file_rimg); ?> www.phpguru.biz. 3.What is the output of 2^2 in php ? The answer is 0 (Zero) Important note
Everyone expected answer would be 4.But answer is zero.How it happened only in php ? The ^ operator is different in each language.In PHP ^ means the bitwise exlusive or of the two numbers.
www.phpguru.biz. 4.What is the output of below script? <?php $x = 3; switch ($x) { case 2: echo 'line 1'; break; case 3: case 4: echo 'line 2'; break; default: echo 'line 3'; } ?> a. echo 'line 3'; b. echo 'line 2'; c. Error d. None of the above Ans: b (Answer is line2)
5.What is the output here? <?php $x = 'ravi'; echo ‘Hello $x’; ?> a. helloravi b. Parse error c. hello $x d. syntax error ANS: c published by www.phpguru.biz. 6.What output do you get here? www.phpguru.biz.com <?php $list = array("clock","scissors","pen","dog"); $list[] = "elephant"; $list[] = "dragon"; print "$list[4]"; ?> a. Error b. elephant c. dog d. nothing ANS: b (elephant) 7.what is the output? <?php echo 10+FALSE; ?> a. 10 b. no c. parse error d. T_ECHO error ANS: 10 www.phpguru.biz. 8.What is the output here? <?php $x=7; if ($x < 2) { echo "11"; } elseif ($x < 16) { echo "12"; } elseif ($x <1 4) { echo "13"; } elseif ($x > 14) { echo "14"; } elseif ($x < 10) { echo "15"; } else { echo "16"; } ?> a.16 b.15 c.14 d.17 ANS:14 9.What is the output here? <?php echo "www.phpguru.biz."; $x = ''; switch ($x) { case "0": echo "String"; br; case 0: echo ""; break; case NULL: echo "NULL"; br; case FALSE: echo "heeder"; br; case "": echo "no string"; br; default: echo "nothing else"; br; } ?> a. Something else b. Empty string c. Integer d. String ANS: Integer 10.What is the answer of following code? <?php function x ($y) { function y ($z) { return ($z*2); } return($y+3); } $y = 4; $y = x($y)*y($y); echo "$y"; ?> a. None b. 54 c. 56 d. 58 ANS:56
|