Junior PHP Developer

  Home  Web Development  Junior PHP Developer


“Junior PHP Developer related Frequently Asked Questions in various Junior PHP Developer job interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting”



161 Junior PHP Developer Questions And Answers

128⟩ Explain what is the difference between for and foreach?

for is expressed as follows:

for (expr1; expr2; expr3)

statement

The first expression is executed once at the beginning. In each iteration, expr2 is evaluated. If it is TRUE, the loop continues and the statements inside for are executed. If it evaluates to FALSE, the execution of the loop ends. expr3 is tested at the end of each iteration.

However, foreach provides an easy way to iterate over arrays and it is only used with arrays and objects.

 144 views

131⟩ Tell me how to create a text file in php?

$filename = "/home/user/guest/myTextFile.txt";

$file = fopen( $filename, "w" );

if( $file == false )

{

echo ( "Error in opening new file" ); exit();

}

fwrite( $file, "This is a simple testn" );

fclose( $file );

 143 views