Tuesday, 4 August 2015

PHP basic interview questions for 2 years experience candidate

1) What is the best practice for running MySQL queries in PHP ? Consider the risk of SQL injection.
2) Name the cryptographic function in PHP returns the longest hash value?
3) Explain implode/explode function ?
4) What will be the output ?
<?php var_dump(10*23); ?>         
       
 
5) What will be the output ?
<?php  echo 5 * 6 /3 + 6* 7; ?>
   
       
 
6) Write a function that will print the all values in the array.
 $array = array(array(12,13,19), 12, 33, array(101, 202, 303));

7) Write down the correct syntax of mail() function?

8) What will be the Output  ?
<?php print null == NULL; ?>
   
       
 

9) What will be the output?
<?php echo '1'.print(2) + 3; ?>
   
       
 

10) What is the difference between die() and exit() in PHP?
11) How can we use register_shutdown_function() in PHP ?
12) How can we use assert() and assert_options in PHP ?
13) Difference between die() and trigger_error() and set_exception_handler() ?
14) How can we delete a file in PHP ?

Thursday, 21 May 2015

Create Virtual Hosts using WAMP in windows

I want to share that how to create virtual host in wamp server in window environment.
For e.g. we want to create virtual host for project name mage-domain
So we simply type http://localhost/mage-domain/ in browser url

now we will create virtual host for same project. So it will be look like as follows:

http://mage-domain.com



A) Go to C:/Windows/System32/drivers/etc.

You will find the file named "hosts". Open this file in Text Editor.

B) Please add a following text line at the end of the file:


127.0.0.1       localhost  //if exists then dont add

::1             localhost //if exists then dont add

#mage-domain.com is added 

127.0.0.1   mage-domain.com

c) Go to D:\wamp\bin\apache\apache2.4.9\conf

Note: Apache version and Computer drive may be vary in terms of individual.
Open the file named "httpd.conf" in Text Editor not "httpd.conf.build".

d) Search for this pharse "# Virtual hosts". 

Remove # tag before the line "Include conf/extra/httpd-vhosts.conf":

Old:

# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
New
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

This will we set our virtual hosts file to Apache.

e) Go to D:\wamp\bin\apache\apache2.4.9\conf\extra

Open the file named "httpd.vhosts.conf".

<VirtualHost *:80>

ServerName mage-domain.com
DocumentRoot D:\wamp\www\php_project
<Directory "D:/wamp/www/php_project/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Note: ServerName and host name (that name we have added in hosts file) both must be same.


f) Restart your wamp server.