Php Objective Questions with Answers for written test exams 25

Question 25
What are the contents of output.txt after the following code snippet is run?


$str = ‘abcdefghijklmnop’;

$fp = fopen(“output.txt”, ‘w’);

for($i=0; $i< 4; $i++) {

fwrite($fp, $str, $i);

}

?>

A. abcd

B. aababcabcd

C. aababc

D. aaaa
Answers 25


The correct answer is C. On the first iteration, $i is 0, so no data is written. On

the second iteration $i is 1, so a is written. On the third, ab is written, and on the

fourth abc is written.Taken together, these are aababc.

  







Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---