41⟩ Tell me how to find the length of a string?
strlen() function used to find the length of a string
“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”
strlen() function used to find the length of a string
To send email using PHP, you use the mail() function. This mail() function accepts 5 parameters as follows (the last 2 are optional). You need webserver, you can't send email from localhost. eg : mail($to,$subject,$message,$headers);
strpos() is used to find the position of the first occurrence of a substring in a string
It is possible to generate HTML through PHP scripts, and it is possible to pass informations from HTML to PHP.
It is possible to use the dedicated function, is_numeric() to check whether it is a number or not.
It is preferable to use crypt() which natively supports several hashing algorithms or the function hash() which supports more variants than crypt() rather than using the common hashing algorithms such as md5, sha1 or sha256 because they are conceived to be fast. hence, hashing passwords with these algorithms can vulnerability.
A session is a logical object enabling us to preserve temporary data across multiple PHP pages.
$_COOKIE is an associative array of variables sent to the current PHP script using the HTTP Cookies.
The goto statement can be placed to enable jumping inside the PHP program. The target is pointed by a label followed by a colon, and the instruction is specified as a goto statement followed by the desired target label.
To be able to verify whether a PHP variable is an instantiated object of a certain class we use instanceof.
The function parse_ini_file() enables us to load in the ini file specified in filename, and returns the settings in it in an associative array.
$_FILES[‘userfile’][‘name’] represents the original name of the file on the client machine,
$_FILES[‘userfile’][‘tmp_name’] represents the temporary filename of the file stored on the server.
__sleep returns the array of all the variables that need to be saved, while __wakeup retrieves them.
The function get_magic_quotes_gpc() tells us whether the magic quotes is switched on or no.
require() and require_once() perform the same task except that the second function checks if the PHP script is already included or not before executing it.
(same for include_once() and include())
This method is best when encode a string to used in a query part of a url. it returns a string in which all non-alphanumeric characters except -_. have replece with a percentege(%) sign . the urldecode->Decodes url to encode string as any %and other symbole are decode by the use of the urldecode() function.
index.php is the default name of the home page in php based sites
It's how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
Split function splits string into array by regular expression. Explode splits a string into array by string.