Prepare Interview

Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address
Check our LIVE MOCK INTERVIEWS

PHP Interview Questions and Answers

Test your skills through the online practice test: PHP Quiz Online Practice Test

Experienced / Expert level questions & answers

Ques 1. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what's the problem?

PHP Interpreter treats numbers beginning with 0 as octal.

Is it helpful? Add Comment View Comments
 

Ques 2. How do I find out the number of parameters passed into function?

func_num_args() function returns the number of parameters passed in.

Is it helpful? Add Comment View Comments
 

Ques 3. If the variable $a is equal to 5 and variable $b is equal to character a, what's the value of $$b?

100, it's a reference to existing variable.

Is it helpful? Add Comment View Comments
 

Ques 4. What's the difference between accessing a class method via -> and via ::?

:: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.

Is it helpful? Add Comment View Comments
 

Ques 5. How come the code <?php print "Contents: $arr[1]"; ?> works, but <?php print "Contents: $arr[1][2]"; ?> doesn't for two-dimensional array of mine? -

Any time you have an array with more than one dimension, complex parsing syntax is required. print "Contents: {$arr[1][2]}" would've worked.

Is it helpful? Add Comment View Comments
 

Ques 6. With a heredoc syntax, do I get variable substitution inside the heredoc contents?

Yes.

Is it helpful? Add Comment View Comments
 

Ques 7. I am writing an application in PHP that outputs a printable version of driving directions. It contains some long sentences, and I am a neat freak, and would like to make sure that no line exceeds 50 characters. How do I accomplish that with PHP?

On large strings that need to be formatted according to some length specifications, use wordwrap() or chunk_split().

Is it helpful? Add Comment View Comments
 

Ques 8. What's the difference between md5(), crc32() and sha1() crypto on PHP?

The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.

Is it helpful? Add Comment View Comments
 

Ques 9. So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()?

Crypto usage in PHP is simple, but that doesn't mean it's free. First off, depending on the data that you're encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

Related differences

PHP vs JSP

Related interview subjects

PHP interview questions and answers - Total 27 questions
jQuery interview questions and answers - Total 22 questions
React interview questions and answers - Total 40 questions
Dojo interview questions and answers - Total 23 questions
Ajax interview questions and answers - Total 58 questions
ASP interview questions and answers - Total 82 questions
Angular interview questions and answers - Total 50 questions
Oracle JET(OJET) interview questions and answers - Total 54 questions
ExtJS interview questions and answers - Total 50 questions
Angular JS interview questions and answers - Total 21 questions
JavaScript interview questions and answers - Total 59 questions
©2023 WithoutBook