Category Archives: PHP Interview Questions

How many ways we can pass the variable through the navigation between the pages? | PHP Questions

At least 3 ways: 1. Put the variable into session in the first page, and get it back from session in the next page. 2. Put the variable into cookie in the first page, and get it back from the … Continue reading

Posted in PHP Interview Questions | Leave a comment

How can we know the count/number of elements of an array? | PHP Questions

2 ways: a) sizeof($array) – This function is an alias of count() b) count($urarray) – This function returns the number of elements in an array. Interestingly if you just pass a simple var instead of an array, count() will return … Continue reading

Posted in PHP Interview Questions | Leave a comment

What are the different functions in sorting an array? | PHP Questions

Sorting functions in PHP: asort() arsort() ksort()krsort() uksort() sort() natsort() rsort()

Posted in PHP Interview Questions | Leave a comment

How can we extract string “abc.com” from a string “mailto:info@abc.com? | PHP Questions

subject=Feedback” using regular expression of PHP? $text = “mailto:info@abc.com?subject=Feedback”; preg_match(‘|.*@([^?]*)|’, $text, $output); echo $output[1]; Note that the second index of $output, $output[1], gives the match, not the first one, $output[0].So if md5() generates the most secure hash, why would you … Continue reading

Posted in PHP Interview Questions | Leave a comment

What’s the difference between htmlentities() and htmlspecialchars()? | PHP Questions

htmlspecialchars only takes care of <, >, single quote ‘, double quote ” and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.

Posted in PHP Interview Questions | Leave a comment

What’s the output of the ucwords function in this example? | PHP Questions

$formatted = ucwords(“TECHPREPARATIONS IS COLLECTION OF INTERVIEW QUESTIONS”); print $formatted; What will be printed is TECHPREPARATIONS IS COLLECTION OF INTERVIEW QUESTIONS. ucwords() makes every first letter of every word capital, but it does not lower-case anything else. To avoid this, … Continue reading

Posted in PHP Interview Questions | Leave a comment

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? | PHP Questions

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

Posted in PHP Interview Questions | Leave a comment

How many ways we can retrieve the date in result set of mysql using php? | PHP Questions

As individual objects so single record or as a set or arrays.Can we use include (“abc.php”) two times in a php page “makeit.php”? Yes.For printing out strings, there are echo, print and printf. Explain the differences. echo is the most … Continue reading

Posted in PHP Interview Questions | Leave a comment

How can we create a database using PHP and mysql? | PHP Questions

We can create MySQL database with the use of mysql_create_db($databaseName) to create a database.

Posted in PHP Interview Questions | Leave a comment

How can we submit form without a submit button? | PHP Questions

We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we can call the document.form.submit() function to submit the form. For example: <input type=button value=”Save” onClick=”document.form.submit()”>

Posted in PHP Interview Questions | Leave a comment