Close
All

Top 10 PHP Interview Questions and Answers

Top 10 PHP Interview Questions and Answers

1
$password = “mysecretpassword”; $hashed_password = hash(“sha256”, $password);
PHP also provides functions such as mcrypt_encrypt() and mcrypt_decrypt() for encrypting and decrypting data using symmetric encryption algorithms.

For example:

1
$plaintext = “mysecretdata”; $key = “mysecretkey”; $ciphertext = mcrypt_encrypt(“rijndael-256”, $key, $plaintext, “cbc”);

  1. How do you debug PHP code?

Debugging PHP code can be done by adding error reporting and debugging code to your scripts. The simplest way to do this is to add the following line of code at the top of your PHP scripts:

1
error_reporting(E_ALL); ini_set(‘display_errors’, 1);
This will display all errors and warnings that occur during the execution of your script. Additionally, you can use the var_dump() function to output the contents of a variable, and the print_r() function to output the contents of an array.

Leave a Reply

Your email address will not be published. Required fields are marked *