Home Interview Questions and Answers PHP Interview questions and Answers For Graduates Part-3

php21. How can we encrypt the username and password using php?

You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD(“Password”);
We can encode data using base64_encode($string) and can decode using base64_decode($string);

22. What is the difference between explode and split?

Split function splits string into array by regular expression. Explode splits a string into array by string.
For Example:explode(” and”, “India and Pakistan and Srilanka”);
split(” :”, “India : Pakistan : Srilanka”);
Both of these functions will return an array that contains India, Pakistan, and Srilanka.

23. How do you define a constant?

Constants in PHP are defined using define() directive, like define(“MYCONSTANT”, 100);

24. How do you pass a variable by value in PHP?

Just like in C++, put an ampersand in front of it, like $a = &$b;

25. What does a special set of tags <?= and ?> do in PHP?

The output is displayed directly to the browser.

26. How do you call a constructor for a parent class?

parent::constructor($value)

27. What’s the special meaning of __sleep and __wakeup?

__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

28. What is the difference between PHP and JavaScript?

javascript is a client side scripting language, so javascript can make popups and other things happens on someone’s PC. While PHP is server side scripting language so it does every stuff with the server.

29. What is the difference between the functions unlink and unset?

unlink() deletes the given file from the file system.
unset() makes a variable undefined.

30. How many ways can we get the value of current session id?

session_id() returns the session id for the current session.

You may also like

Leave a Comment