Archive for the ‘ PHP Interview Questions ’ Category
How To Protect Special Characters in Query String in PHP?
on May 5, 2010
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 …
Unlink() is a function for file system handling. It deletes 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?
on May 1, 2010
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 file: ".strlen($file)."\n"); ?> This script …
A True Definition of PHP Developer
on April 23, 2010
In my opinion a true developer is someone who more focuses on business goal and application design than coding. For developers, PHP 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 follows the same path in PHP as he would do …
How Can We Define SESSION Variable in JAVASCRIPT?
on March 24, 2010
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 asynchronous.
What Is a Session?
on March 19, 2010
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 for the same visitor.
Check or Uncheck All in a Group of Checkbox in JavaScript
on March 11, 2010
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> …
Get Last Visited Page or URL in PHP
on March 9, 2010
If you will go to 1 page to 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
on March 8, 2010
HTTP_ACCEPT A list of MIME types the client will accept. HTTP_ACCEPT_LANGUAGE What type of languages the browser expects. These are human languages, 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. …
How to Upload Files Using HTML and PHP?
on March 7, 2010
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 = "FileDirectory/"; /* wrong file type – not a doc type file*/ if (substr($_FILES[’myfile’][’name’],strlen($_FILES[’myfile’][’name’])-4,4)!=’.doc’){ echo "Failed upload!";} /* the path where file will be …

