All In One
PHP and MySQL Revolution
Friday, June 14, 2013
Online php exam
Part 1: Apache
Question 1:
Assume PHP5 and apache 2.2 is installed on XP, what need to be done on Apache configuration file to make it able to run PHP as Apache module?
Your answer?
Question 2:
If there is one IP address(10.111.203.25), then how to host two web sites(web1.test.com,web2.test.com) on server ?
Your answer?
Using Virtual URL feature of Apache we can run multiple domainsm on same IT.
DocumentRoot /www/example1 ServerName web1.test.com # Other directives here
DocumentRoot /www/example2 ServerName web2.test.com # Other directives here
Question 3:
How to benchmark apache server?
Your answer?
You can benchmark Apache, IIS and other web server with apache benchmarking tool called ab. ab -n 1000 -c 10 http://www.abc.com/test.html
Question 4:
How to enable basic authentication in apache for a directory?
Your answer?
using .htaccess and .htpasswd files to create a password file with users. We will use the htpasswd utility provided in the core Apache package. The password file can be stored anywhere on your hard drive. In our example we will create our htpasswd file in /etc/htpasswd. You just need to specify the full path to the htpasswd file with the AuthUserFile directive. Choose whatever you deem to be a sane location for your password files. /path/to/htpasswd -c /etc/htpasswd/.htpasswd user1
Question 5:
How do I turn automatic directory listings on or off in Apache configuration?
Your answer?
index off on /var/www (in my conf.d file) index off on /var/www/exampledir (in my conf.d file)
Part 2: MySQL
Question 6:
Use MySQL command line to create/execute a store procedure with one integer input to return its factorial value (5! = 5*4*3*2*1)
Your answer?
mysql> DELIMITER // mysql> create procedure usp_GetEmployeeName(IN id INT, OUT name VARCHAR(20)) -> begin -> select emp_name into name from employee where emp_id = id; -> end//
Question 7:
Explain difference between two MySQL storage engine: InnoDB and MyISAM?
Your answer?
Innodb : 1. Row level locking 2. supports transaction 3. foreign key constraints 4. row count is not stored internally and so slow COUNT(*)s 5. stores both data and indexes in one file MyISAM 1. table-level locking 2. does not support transactions 3. no foreign key constraints 4. row count is stored internally and so fast COUNT(*)s 5. stores indexes in one file and data in another
Question 8:
How to backup and restore a MySql database between servers?
Your answer?
To backup the databases please do the following: Method 1. Login to your control panel and click Backups. Under Download a MySQL Database Backup, click the name of the database. Click Save As. Select a destination for where you would like the back up to be saved, locally. Method 2. Login in Phpmyadmin and use import and export feature of this. Method 3. We can use the mysqldump commmand to backup databse.
Question 9:
Select records from 'pet' table which 'name' attribute start with either case of B
Your answer?
Select * from pet where name Like 'B%' COLLATE utf_general_ci
Question 10:
Assume you have no knowledge of its metadata, how to you try to find out the tables and then check the schema of a table in the database of MySQL?
Your answer?
To see the schema of a table, use DESCRIBE table_name; OR select table_name from information_schema.tables where table_schema = 'your_db'
Part 3: JQuery
Question 11:
Using short JQuery script to set 'Toronto' in the 'CanCity' list to invisible but keep its space.
Your answer?
$("#CanCity ul").append('
Toronto
').hide();
Question 12:
Wrote Jquery code to dim the text
Remarque
and disable the button after user click on the dialog button.
Your answer?
Assumptions 1. #dialog is id of dialog box 2. #labelid is of Remarks label $("#dialog").click(function(){ $("#labelid").css('color', 'gray'); $("input[type=submit]").attr("disabled", "disabled"); } );
Question 13:
Explain the difference of function
bind
,
live
,
delegate
in Jquery
Your answer?
All the three jQuery functions are used to attach events to selectors or elements. But just think why there are 3 different functions for same purpose? bind() vs live() The basic difference between bind and live is bind will not attach the event handler to those elements which are added/appended after DOM is loaded. bind() only attach events to the current elements not future element. bind() vs delegate() The difference between bind and delegate is same as how bind differs from live function. I had explained the difference with an example in this post jQuery delegate function live() vs delegate() As we had seen the advantage of live and delegate function that they attaches event to those elements also which are added/appended after DOM is loaded. But how they both are different?
Question 14:
How to check element with id 'divTxt' exist or not?
Your answer?
using .html funtion of jquery we can check this.
Question 15:
How to increment all li node's value by 1?
Your answer?
$('ul li').each(function(i,el){ el.id = i+1; });
Part 4: CodeIgniter
Question 16:
Why CodeIgniter does not use template engine?
Your answer?
CodeIgniter does come with a simple template parser that can be optionally used
Question 17:
To remove the index.php file in CodeIgniter, assume you are using Apache as web server, you could ...
Your answer?
Yes we can do this using .htaccess file RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
Question 18:
You usually save your controller in which folder?
Your answer?
version 1.3 system/application/controllers version 2.0 application/controllers
Question 19:
In CodeIgniter, the second segment of the URI typically determines ...
Your answer?
To function of controller
Question 20:
If you want to auto load a model what will you do?
Your answer?
We can load in database.php file $this->load->model('Model_name', '', $config);
Part 5: AJAX
Question 21:
Write short code to initialize AJAX asynchronous connection which works in all browsers.
Your answer?
XMLHttpRequest
Question 22:
The server returns your AJAX call in XML format with following status string
<div id='status'>good</div>
.
Write short code to update the
responseOutput
element to show the status of the ajax call. <div id='responseOutput'> </div>
Your answer?
var rssentries=xmldata.getElementsById("status") $("#responseOutput").val(rssentries);
Question 23:
Server is expecting a JSON string for your AJAX call. How do you send the name(John Doe) and time(2pm) to server?
Your answer?
postData.push({ "name": John Doe, "time": 2pm }); postData = JSON.stringify(postData); $.ajax({ url: 'test/test.php', type: 'POST', data: postData, contentType: "application/json; charset=utf-8", dataType: "json", success: function () { window.alert('@Resource.AjaxSuccess'); }, }, });
Question 24:
How do I create a thread to do AJAX polling?
Your answer?
JavaScript does not have threads. JavaScript functions are called when an event happens in a page such as the page is loaded, a mouse click, or a form element gains focus. You can create a timer using the setTimeout which takes a function name and time in milliseconds as arguments. You can then loop by calling the same function as can be seen in the JavaScript example below. function checkForMessage() { // start AJAX interaction with processCallback as the callback function } // callback for the request function processCallback() { // do post processing setTimeout("checkForMessage()", 10000); } - See more at: http://www.debuggersden.com/questions/how-do-i-create-a-thread-to-do-ajax-polling/#sthash.bZMS9JIh.dpuf
Question 25:
How do you update ajax response with id
results
using Jquery.
Your answer?
Its correct
Part 6: HTML5
Question 26:
What is the sessionStorage Object in html5 ? How to create and access ?
Your answer?
With HTML5, web pages can store data locally within the user's browser
Question 27:
How to define doctype in html5
Your answer?
Question 28:
How to do Geolocation in HTML5? Wrote a short code to get current latitude and longitude.
Your answer?
Question 29:
How to do video using HTML5?
Your answer?
Question 30:
Wrote a short snippet using new HTML5 tags which include a header, navigation bar, sidebar, footer and a main section. The main section includes an article.
Your answer?
Part 7: REST/SOAP/JSON
Question 31:
What is the main difference between RESTful and SOAP?
Your answer?
Question 32:
How to retrieve array object from PHP while requesting from an URL which returns a JSON string?
Your answer?
Question 33:
Explain standards used in web services?
Your answer?
Question 34:
What's the main use of SOAP header?
Your answer?
Question 35:
Which HTTP methods are supported by RestFul web service?
Your answer?
Part 8: PHP
Question 36:
Tell me about basic types of runtime errors in PHP.
Your answer?
strict warning notice fatal
Question 37:
The form below is for file upload. How do you retrieve the upload file name and size in PHP on server end?
Your answer?
Question 38:
How do you print following PHP string into output HTML as it is?
Your answer?
Question 39:
How to construct header object to send mail with file attachment in following PHP function call?
mail($to,$subject,$message,$header)
Your answer?
Question 40:
How can we extract domain name
scotiabank.com
from URL
'http://webmaster@scotiabank.com/cgi-bin/a.cgi?lang=FR'
using regular expression in PHP?
Your answer?
Finish
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Contact Form
Name
Email
*
Message
*
No comments:
Post a Comment