Sharag Web

Get All Information

Aztecsoft php web developer interview

Aztecsoft php web developer interview questions with answers

1) how to increase the web page performance ?
1) Use lightweight templates
2) Put Stylesheets at the Top
3) Put Scripts at the Bottom
4) Avoid CSS Expressions like As an example, the background color could be set to alternate every hour using CSS expressions.
background-color: expression( (new Date()).getHours()%2 ? “#B8D4FF” : “#F08A00” );
5) Make JavaScript and CSS External
6) Minify JavaScript and CSS : Minification is the practice of removing unnecessary characters from code to reduce its size thereby improving load times.
7) Remove Duplicate Scripts
8) Choose over @import
9) Don’t Scale Images in HTML
10) Make favicon.ico Small and Cacheable
11) use Ajax, JSON, Jquery for fastening results

2) $test=array( 0=>’one’ , 2=> ‘two’ , ‘3 ‘=>’three’ , ‘3a’=>5, ‘myindex’); print_r($test); what will be the output? 
Array ( [0] => one [2] => two [3 ] => three [3a] => 5 [3] => myindex )
3) what is output of this mysql function select substring_index(‘’,”@”,-1); 
Ans:   explanation is below

Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.

mysql> SELECT SUBSTRING_INDEX('', '.', 2); -> 'www.mysql' mysql> SELECT SUBSTRING_INDEX('', '.', -2); -> ''

This function is multi-byte safe.

4) An employee table having columns  id {employee id} , name {employee name},  m_id {manager id }  , write a query to select employee and their manager names  ? 

Main table
id name m_id
1 John 2
2 Greek Tor 1
3 Alex John 1
4 Mike tour 1
5 Brain J 3
6 Ronald 3
7 Kin 4
8 Herod 3
9 Alen 2
10 Ronne 1

Ans:  INNER join SQL command is mostly used to join one table to it self. The biggest advantage of doing this is to get linking information from the same table. We will try to understand this with an example. The best example of INNER join will be employee table where we will keep the employee and its manager as a single record. This way by linking to the table it self we will generate a report displaying it as two linked tables. Each record will have one additional field storing the data of the manager by keeping the employee ID and we will use M_ID ( manager ID ) to link with main employee ID. This way we will link two virtual tables generated from one main table. 
let us use inner join to create one report on who is the manager of which employee. Check this SQL
SELECT, as emp_name, as manager FROM emp as t1 INNER JOIN emp as t2 on = t1.m_id

id emp_name manager
1 John Greek Tor
2 Greek Tor John
3 Alex John John
4 Mike tour John
5 Brain J Alex John
6 Ronald Alex John
7 Kin Mike tour
8 Herod Alex John
9 Alen Greek Tor
10 Ronne John

for more :  To generate only the manager table used this SQL
SELECT, as emp_name from emp as t1 INNER JOIN emp as t2 on
Managers Table

id emp_name
2 Greek Tor
1 John
1 John
1 John
3 Alex John
3 Alex John
4 Mike tour
3 Alex John
2 Greek Tor
1 John

To generate only the employee table  used this SQL
SELECT, as emp_name from emp as t1 INNER JOIN emp as t2 on

id emp_name
1 John
2 Greek Tor
3 Alex John
4 Mike tour
5 Brain J
6 Ronald
7 Kin
8 Herod
9 Alen
10 Ronne

use below dump for your reference
`id` int(4) NOT NULL auto_increment,
`name` varchar(25) NOT NULL default ”,
`m_id` int(4) NOT NULL default ‘0’,
UNIQUE KEY `id` (`id`)

— Dumping data for table `emp`

INSERT INTO `emp` VALUES (1, ‘John’, 2);
INSERT INTO `emp` VALUES (2, ‘Greek Tor’, 1);
INSERT INTO `emp` VALUES (3, ‘Alex John’, 1);
INSERT INTO `emp` VALUES (4, ‘Mike tour’, 1);
INSERT INTO `emp` VALUES (5, ‘Brain J’, 3);
INSERT INTO `emp` VALUES (6, ‘Ronald’, 3);
INSERT INTO `emp` VALUES (7, ‘Kin’, 4);
INSERT INTO `emp` VALUES (8, ‘Herod’, 3);
INSERT INTO `emp` VALUES (9, ‘Alen’, 2);
INSERT INTO `emp` VALUES (10, ‘Ronne’, 1);

5) write code to read the following file content “rag.txt”  and replace postgre SQL to MySQL and output the content ?
The postgre SQL database has become the world’s most popular open source database because of its consistent fast performance, high reliability and ease of use. postgre SQL used on every continent — Yes, even Antarctica! — by individual Web developers as well as many of the world’s largest and fastest-growing organizations to save time and money powering their high-volume Web sites, business-critical systems and packaged software by postgre SQL.
$str = file_get_contents(‘rag.txt’);
$str = str_replace(‘postgre SQL’ ,’MySQL’, $str);
echo $str;

6) how we can destroy session cookie?
Ans: we can use session_destroy() or  to destroy particular cookie set it to past time using  setcookie () function like  setcookie (“TestCookie”, “”, time() – 3600);
7) True or False 
a) session_destroy()  : destroys all of the data from session   TRUE
b) session_unset() : frees all session variable  TRUE

c) unset($_SESSION) deletes all session data   FALSE    “Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of session variables through the $_SESSION superglobal.”  
8) $array = array( “hi”, “Hello World” , “what”, “Good Morning”);  write code to output the array contents havng more than one word ?

<? $array = array( “hi”, “Hello World” , “what”, “Good Morning”); 
$count = sizeof($array);
$i =0;
while ($i < $count )
echo “<br> ***********<br>”;
$exp = explode ( ” ” ,$array[$i] );
if (count($exp) > 1)
echo $array[$i] .” is having more than  one word in “. $i.” position of array  <br>”;
9) what is the output of the below code 
$sec_array = array(“red”, “green”, “blue”,”yellow”);
array_splice( $sec_array , 1, -1);
print_r($sec_array );   ? 
Ans: Array ( [0] => red [1] => yellow )
10) how we can get the second value from the last in an array ?
example  <? 
$check = array ( “rag”, “shara”, “sharag”, “man”,”woman”,”child”, “human”);
echo $check[count($check)-2];

11)  What is the maximum length of a URL?
Microsoft states that the maximum length of a URL in Internet Explorer is 2,083 characters, with no more than 2,048 characters in the path portion of the URL
Firefox, Safari , Opera  supports more than 100,000 characters.  but some times server like Apache, IIS may not support these longer URL’s. so better to keep it short URL.


Leave a Reply

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

You cannot copy content of this page