Archive for the ‘PHP Interview Questions’ Category

How To Protect Special Characters in Query String in PHP?

Wednesday, May 5, 2010 12:02 1 Comment

If you want to include special characters like spaces in the query string, you need to protect them by applying the urlencode() translation function. The script below shows how to use urlencode():

<?php

print("<html>");

print("<p>Please click the links below to submit comments about FYICenter.com:</p>");

$comment = ‘I want to say: "It\’s a good site! :->"’;
$comment = urlencode($comment);

print("<p>"
."<a href=\"processing_forms.php?name=Guest&comment=$comment\">"
."It’s an [...]

This was posted under category: PHP Interview Questions

What is the difference between the functions unlink and unset?

Monday, May 3, 2010 11:53 No Comments

unlink() is a function for file system handling. It deleted any file.
unset() is a function for variable management. It deletes/unset a given variable.

This was posted under category: PHP Interview Questions

How To Read the Entire File into a Single String?

Saturday, May 1, 2010 11:50 No Comments

If you have a file, and you want to read the entire file into a single string, you can use the file_get_contents() function. It opens the specified file, reads all characters in the file, and returns them in a single string. Here is a PHP script example on how to file_get_contents():

<?php
$file = file_get_contents("/windows/system32/drivers/etc/services");
print("Size of the [...]

This was posted under category: PHP Interview Questions

True PHP Developer Definition

Friday, April 23, 2010 15:26 No Comments

In my opinion a true developer is someone who is more focused on business goal and application design than coding. PHP for developer is just a tool – a very flexible one indeed and very easy to start with – but it also offers great possibilities even for more experienced programmers. The true developer would [...]

This was posted under category: PHP Interview Questions

How can we define SESSION variable in JAVASCRIPT ?

Wednesday, March 24, 2010 11:33 No Comments

It’s not possible to set any session variables directly from java-script as it is purely a client side technology. You can use AJAX though to asynchronously.

This was posted under category: Javascript, PHP Interview Questions

What is a Session?

Friday, March 19, 2010 15:05 No Comments

There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor.
Sessions are commonly used to store temporary data to allow multiple PHP pagesto offer a complete functional transaction [...]

This was posted under category: PHP Interview Questions

Check or Uncheck all in a group of checkbox in JavaScript

Thursday, March 11, 2010 3:23 1 Comment

JavaScript code to be kept before head tag.

<SCRIPT LANGUAGE="JavaScript">
function CheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}

function UnCheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}
</script>

HTML Code:

<form name="myform" action="checkboxes.asp" method="post">
<b>Scripts for Web design and programming</b><br>
<input type="checkbox" name="check_list" value="1">ASP<br>
<input type="checkbox" name="check_list" value="2">PHP<br>
<input type="checkbox" name="check_list" value="3">JavaScript<br>
<input type="checkbox" name="check_list" value="4">HTML<br>
<input type="checkbox" name="check_list" value="5">MySQL<br>

<input [...]

This was posted under category: ASP/.NET, PHP Interview Questions

Get last visited Page or URL in PHP

Tuesday, March 9, 2010 12:15 No Comments

If you will go to 1 page to another page on second page it will display that you have come from Page 1.

// index.php
<a href="index2.php">Go to index2</a>

// index2.php
echo $_SERVER['HTTP_REFERER']; // Display index.php

This was posted under category: PHP Interview Questions

Get Statistics of your website Using PHP

Monday, March 8, 2010 12:22 1 Comment

HTTP_ACCEPT
A list of MIME types the client will accept.
HTTP_ACCEPT_LANGUAGE
What type of languages the browser expects.
These are human language, such as en-us, to represent, English, United States.
HTTP_CONNECTION
The type of connection established between the client and the Web server.
HTTP_HOST
The hostname of the client computer.
HTTP_USER_AGENT
The browser type and version, and operating system information of the client.
HTTP_REFERER
The full URL [...]

This was posted under category: PHP Interview Questions

How to upload files using HTML and PHP ?

Sunday, March 7, 2010 12:02 No Comments

HTML Code:

<form enctype="application/x-www-form-urlencoded" action="script.php" method="post">
<input type="file" name="myfile" />
<input type="submit" name="submit" value="Upload" />
</form>

PHP Code :

<?php/* File name is null */
if($_FILES[’file’][’name’]==’’){
/* the path to the directory for upload*/
$target_path =’null’;die();
}
else{
$target_path [...]

This was posted under category: PHP Interview Questions