Warning: Cannot modify header information - headers already sent by (output started at /home/imjan/public_html/wp-content/themes/Prima/functions.php:347) in /home/imjan/public_html/wp-includes/feed-rss2.php on line 8
Internet Methodologies Journal And News » PHP Interview Questions http://www.imjan.com Sharing is Learning Sat, 21 May 2011 19:11:15 +0000 en hourly 1 http://wordpress.org/?v=3.0.5 How To Protect Special Characters in Query String in PHP? http://www.imjan.com/web-development/php-interview-questions/how-to-protect-special-characters-in-query-string-in-php/ http://www.imjan.com/web-development/php-interview-questions/how-to-protect-special-characters-in-query-string-in-php/#comments Wed, 05 May 2010 12:02:25 +0000 imran http://www.imjan.com/?p=1071 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 excellent site!</a></p>");

$comment = 'This visitor said: "It\'s an average site! :-( "';
$comment = urlencode($comment);

print("<p>"
.'<a href="processing_forms.php?'.$comment.'">'
."It's an average site.</a></p>");
print("</html>");
?>
]]>
http://www.imjan.com/web-development/php-interview-questions/how-to-protect-special-characters-in-query-string-in-php/feed/ 0
What is the Difference Between the Functions Unlink and Unset? http://www.imjan.com/web-development/php-interview-questions/what-is-the-difference-between-the-functions-unlink-and-unset/ http://www.imjan.com/web-development/php-interview-questions/what-is-the-difference-between-the-functions-unlink-and-unset/#comments Mon, 03 May 2010 11:53:41 +0000 imran http://www.imjan.com/?p=1068 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.

]]>
http://www.imjan.com/web-development/php-interview-questions/what-is-the-difference-between-the-functions-unlink-and-unset/feed/ 0
How To Read the Entire File into a Single String? http://www.imjan.com/web-development/php-interview-questions/how-to-read-the-entire-file-into-a-single-string/ http://www.imjan.com/web-development/php-interview-questions/how-to-read-the-entire-file-into-a-single-string/#comments Sat, 01 May 2010 11:50:17 +0000 imran http://www.imjan.com/?p=1064 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 will be printed:

Size of the file: 7116
]]>
http://www.imjan.com/web-development/php-interview-questions/how-to-read-the-entire-file-into-a-single-string/feed/ 0
A True Definition of PHP Developer http://www.imjan.com/web-development/php-interview-questions/true-php-developer-definition/ http://www.imjan.com/web-development/php-interview-questions/true-php-developer-definition/#comments Fri, 23 Apr 2010 15:26:37 +0000 imran http://www.imjan.com/?p=1050 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 in Java or C#

I would say a scripter is – by comparison – someone who completes his task with PHP without concerning about application structure and business model – just to finish things off, and PHP is a dangerous tool for that due to its relative simplicity and great popularity. Scripter forced to use programming language other than PHP would almost surely be confused and have to rethink his whole approach to the problem.

So I’d say this is what separates those two kinds of IT workers.

]]>
http://www.imjan.com/web-development/php-interview-questions/true-php-developer-definition/feed/ 0
How Can We Define SESSION Variable in JAVASCRIPT? http://www.imjan.com/web-development/javascript/how-can-we-define-session-variable-in-javascript/ http://www.imjan.com/web-development/javascript/how-can-we-define-session-variable-in-javascript/#comments Wed, 24 Mar 2010 11:33:55 +0000 imran http://www.imjan.com/?p=983 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.

]]>
http://www.imjan.com/web-development/javascript/how-can-we-define-session-variable-in-javascript/feed/ 0
What Is a Session? http://www.imjan.com/web-development/php-interview-questions/what-is-a-session/ http://www.imjan.com/web-development/php-interview-questions/what-is-a-session/#comments Fri, 19 Mar 2010 15:05:33 +0000 imran http://www.imjan.com/?p=970 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.

]]>
http://www.imjan.com/web-development/php-interview-questions/what-is-a-session/feed/ 0
Check or Uncheck All in a Group of Checkbox in JavaScript http://www.imjan.com/web-development/curl-php-examples/check-or-uncheck-all-in-a-group-of-checkbox-in-javascript/ http://www.imjan.com/web-development/curl-php-examples/check-or-uncheck-all-in-a-group-of-checkbox-in-javascript/#comments Thu, 11 Mar 2010 03:23:57 +0000 imran http://www.imjan.com/?p=866 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 type="button" name="Check_All" value="Check All"
onClick="CheckAll(document.myform.check_list)">
<input type="button" name="Un_CheckAll" value="Uncheck All"
onClick="UnCheckAll(document.myform.check_list)">
]]>
http://www.imjan.com/web-development/curl-php-examples/check-or-uncheck-all-in-a-group-of-checkbox-in-javascript/feed/ 2
Get Last Visited Page or URL in PHP http://www.imjan.com/web-development/php-interview-questions/get-last-visited-page-or-url-in-php/ http://www.imjan.com/web-development/php-interview-questions/get-last-visited-page-or-url-in-php/#comments Tue, 09 Mar 2010 12:15:01 +0000 imran http://www.imjan.com/?p=840 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
]]>
http://www.imjan.com/web-development/php-interview-questions/get-last-visited-page-or-url-in-php/feed/ 0
Get Statistics of Your Website Using PHP http://www.imjan.com/web-development/php-interview-questions/get-statistics-of-your-website-using-php/ http://www.imjan.com/web-development/php-interview-questions/get-statistics-of-your-website-using-php/#comments Mon, 08 Mar 2010 12:22:07 +0000 imran http://www.imjan.com/?p=843 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.

HTTP_REFERER
The full URL of the Web page containing the hyperlink used to reach the currently executing ASP page.

HTTP_COOKIE
The cookies sent from the browser.

]]>
http://www.imjan.com/web-development/php-interview-questions/get-statistics-of-your-website-using-php/feed/ 1
How to Upload Files Using HTML and PHP? http://www.imjan.com/web-development/php-interview-questions/how-to-upload-files-using-html-and-php/ http://www.imjan.com/web-development/php-interview-questions/how-to-upload-files-using-html-and-php/#comments Sun, 07 Mar 2010 12:02:53 +0000 imran http://www.imjan.com/?p=835 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 put */
             $target_path = 'path_here' ;
             if (!move_uploaded_file($_FILES[’myfile’][’tmp_name’], $target_path)){
                 /* error during upload */
                echo "Error!";die ();
             }
        }
?>
]]>
http://www.imjan.com/web-development/php-interview-questions/how-to-upload-files-using-html-and-php/feed/ 0