PHP Interview QuestionsDownload PHP Interview Questions PDF
PHP Interview Questions
It is clear from the name SHA256 that the length is of 256 bits long. If you are using hexadecimal representation, then you require 64 digits to replace 256 bits, as one digit represents four bits. Or if you are using a binary representation which means one byte equals to eight bits, then you need 32 digits.
MIME stands for Multipurpose Internet Mail Extensions is an extension of the email protocol. It supports exchanging of various data files such as audio, video, application programs, and many others on the internet. It can also handle ASCII texts and Simple Mail Transport Protocol on the internet.
An access specifier is a code element that is used to determine which part of the program is allowed to access a particular variable or other information. Different programming languages have different syntax to declare access specifiers. There are three types of access specifiers in PHP which are:
- Private: Members of a class are declared as private and they can be accessed only from that class.
- Protected: The class members declared as protected can be accessed from that class or from the inherited class.
- Public: The class members declared as public can be accessed from everywhere.
The explode() and split() functions are used in PHP to split the strings. Both are defined here:
Split() is used to split a string into an array using a regular expression whereas explode() is used to split the string by string using the delimiter.
Example of split():
split(":", "this:is:a:split"); //returns an array that contains this, is, a, split.
Output: Array ( => this, => is, => a, => split)
Example of explode():
explode ("take", "take a explode example "); //returns an array which have value "a explode example"
Output: array( => "a explode example")
It is easy and simple to execute PHP scripts from the windows command prompt. You just follow the below steps:
1. Open the command prompt. Click on Start button->Command Prompt.
2. In the Command Prompt, write the full path to the PHP executable(php.exe) which is followed by the full path of a script that you want to execute. You must add space in between each component. It means to navigate the command to your script location.
let you have placed PHP in C:\PHP, and your script is in C:\PHP\sample-php-script.php,
then your command line will be:
3. Press the enter key and your script will execute.
You can use a .htaccess file to block the direct access of directory in PHP. It would be best if you add all the files in one directory, to which you want to deny access.
For Apache, you can use this code:
<< Order deny, allow Deny from all</<
But first, you have to create a .htaccess file, if it is not present. Create the .htaccess file in the root of your server and then apply the above rule.
These are the commonly used regular expressions in PHP. These are an inbuilt function that is used to work with other regular functions.
preg-Match: This is the function used to match a pattern in a defined string. If the patterns match with string, it returns true otherwise it returns false.
Preg_replace: This function is used to perform a replace operation. In this, it first matches the pattern in the string and if pattern matched, ten replace that match with the specified pattern.
The mail function is used in PHP to send emails directly from script or website. It takes five parameters as an argument.
Syntax of mail (): mail (to, subject, message, headers, parameters);
- to refers to the receiver of the email
- Subject refers to the subject of an email
- the message defines the content to be sent where each line separated with /n and also one line can't exceed 70 characters.
- Headers refer to additional information like from, Cc, Bcc. These are optional.
- Parameters refer to an additional parameter to the send mail program. It is also optional
- Session and cookie both are used to store values or data.
- cookie stores data in your browser and a session is stored on the server.
- Session destroys that when browser close and cookie delete when set time expires.
PHP count function is used to get the length or numbers of elements in an array
<?php // initializing an array in PHP $array=['a','b','c']; // Outputs 3 echo count($array); ?>
Subscribe Our NewsLetter
Never Miss an Articles from us.
- Common Interview Questions
- Python Flask Interview Questions
- NoSQL interview questions
- JQuery Interview Questions
- C programming interview questions
- AngularJS Interview Questions
- Node JS Interview Questions with Express
- Core Java interview questions
- HTML Interview Questions
- Laravel interview questions
- Wordpress Interview Questions
- Core PHP Interview Questions