Monday 11 May 2015

PHP Frequently asked Questions and Answer 2015

PHP Frequently asked Auestions and Answer 2015



Question: What is PHP?
PHP is a server-side scripting language which is used to create the dynamic web pages.


Question: Who is fater of PHP?
Rasmus Lerdorf


Question: Which language is used to Implementation?
C/C++


Question: What is offical website of PHP?
http://php.net/


Question: What is current statable version of PHP?
Version: 7.0.6 Dated April 29, 2016.


Question: What is extensions of PHP File?
.php, .phtml, .php4, .php3, .php5, .phps


Question: Describe how PHP Works with Browser?
Works in following Flow
1. Open website http://www.web-technology-experts-notes.in/
2. Request send to server of http://www.web-technology-experts-notes.in/
3. Call PHP Files.
4. PHP Scripts are loaded into memory and compiled into Zend opcode.
5. These opcodes are executed and the HTML generated.
6. Same HTML is send back to Browser.

Know more: http://www.web-technology-experts-notes.in/2012/07/what-is-zend-engine-in-php.html


Question: What are important things about php functions?
PHP function start with "function function-name()".
PHP Function name must be start with character and it accept alphanumeric and _.
In build functions are case in-sensitive.
User build functions are case sensitive.
We can pass upto 64 parameter as argument.
Anonymous function are user defined function which have "no-name" and also called closures.
PHP support variable functions. Means when you can call a function using variable.
In same file OR under same class, same function name can't be created.


Question: What is role of htmlentities?
htmlentities is used to convert all applicable characters to HTML entities.
It is used to stop the user from running malicious code in HTML.
With use of htmlentities, user can't run the html tags like h2, p, script etc. It helps to prevent you from XSS attack.
echo htmlentities($userData);



Question: How to use email with PHP?
Email functionality is inbuilt with PHP.
PHP provide mail() with use of this, we can sen an email to user or subscriber.
We can send html/text email.
We can send attachment with email.
We can also use option like cc, bc and bcc.
We can also set the values in header.
We can also use third party API like (gmail, yahoo etc) to send email.


Question: How session and cookie works together?
Create an session in PHP.
Session data is stored in Server.
Session data have unique name.
Session unique key with domain name is stored in browser cookie.
Now, Browser keep the login with use of unique key(in cookie) and session data (stored in server side).


Question: What is the difference between the functions unlink and unset?
unlink: delete the files from Server.
unset: delete the variable name and data from memory.


Question: How to create subdomain?
With use virtual host and htaccess, you can create sub domain.


Question: What are the various methods to pass data from one web page to another web page?
Session
Cookie
Database
URL parameters



Question: What are super global variables?
$_COOKIE – Stored information in Cookie.
$_GET – Send data in URL as paramter.
$_POST – Send data to server OR Page as POST Method.
$_REQUEST – Its combined array containing values from the $_GET, $_POST and $_COOKIES.
$_ENV – Get/Set varaible in environment.
$_FILES – Used to upload the file, image and videos etc.
$_SERVER – It have all server information.
$GLOBALS – Contains all the global variables associated with the current script.


Question: How to get a user's IP address of client.
echo $_SESSION['REMOTE_ADDR'];


Question: What type of inheritance supported by PHP?
Single inheritance.
Multiple Level inheritance.


Question: What is CMS?
CMS means Content Management System. It is web software who provide the website full fledged content management where owner can add/update/delete the html/files/images/videos etc. Today's CMS do much more as compare to its name.
For example. Joomla/Wordpress is CMS but you can create E-commererce website and can accpet all types of payment.
In Today's CMS, you can create many different types of website like Ecommerce website, Personal blogging and Forum etc.


Question: How to create unique random password?
echo md5(uniqid(rand(), true));


Question: What is the difference between echo and print?
echo constructor which is used to display the value in browser.
print is function which is used to display and return the value.


Question: What is the difference between characters \023 and \x23?
\023 is octal 23.
\x23 is hex 23.