Archive for the ‘PHP Interview Questions’ Category
How To Protect Special Characters in Query String in PHP?
Wednesday, May 5, 2010 12:02 1 CommentIf 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 [...]
What is the difference between the functions unlink and unset?
Monday, May 3, 2010 11:53 No Commentsunlink() is a function for file system handling. It deleted any file.
unset() is a function for variable management. It deletes/unset a given variable.
How To Read the Entire File into a Single String?
Saturday, May 1, 2010 11:50 No CommentsIf 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 [...]
True PHP Developer Definition
Friday, April 23, 2010 15:26 No CommentsIn 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 [...]
How can we define SESSION variable in JAVASCRIPT ?
Wednesday, March 24, 2010 11:33 No CommentsIt’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.
What is a Session?
Friday, March 19, 2010 15:05 No CommentsThere 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 [...]
Check or Uncheck all in a group of checkbox in JavaScript
Thursday, March 11, 2010 3:23 1 CommentJavaScript 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 [...]
Get last visited Page or URL in PHP
Tuesday, March 9, 2010 12:15 No CommentsIf 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
Get Statistics of your website Using PHP
Monday, March 8, 2010 12:22 1 CommentHTTP_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 [...]
How to upload files using HTML and PHP ?
Sunday, March 7, 2010 12:02 No CommentsHTML 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 [...]


