Monday, March 21, 2011

IMP Questions for PHP / HTML

  • Write PHP code to find out current date in DD/MM/YYYY format. 
     Ans:




  • Give the difference between $_GET and $_POST
   And:  HP provides two special functions called $_GET & $_POST, this functions are used to get the values which are passed from a user-filled form, like user registration or login form etc.
 
$_GET is less secure and effective than $_ POST, $_GET has few limitations like it can send about 100 words of data at a time, whereas $_POST does not have such kind of limitations, we can send any amount of data using this variable. $_POST is more secure than $_GET in the means of that whenever we send data from one web page to another using $_GET variable we can see the values in address bar, on the contrary $_POST does not allow any thing to be displayed in address bar of the browser.


    • What is cookie? Explain with example.
     



    • Explain in detail advantages of PHP
     PHP is one of the most popular server side scripting languages running today. It is used for creating dynamic webpages that interact with the user offering customized information. PHP offers many advantages; it is fast, stable, secure, easy to use and open source (free).


    • Explain PHP variables and also explain why PHP is a loosely typed language?
    Variables are used for storing values, like text strings, numbers or arrays. When a variable is declared, it can be used over and over again in your script. All variables in PHP start with a $ sign symbol. The correct way of declaring a variable in PHP: $var_name = value; 

    In PHP, a variable does not need to be declared before adding a value to it.
    In the example above, you see that you do not have to tell PHP which data type the variable is.
    PHP automatically converts the variable to the correct data type, depending on its value.
    In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it.



    • Give syntax of date() function.

    Syntax

    date(format,timestamp





    • Give syntax of mktime() function

    Syntax

    mktime(hour,minute,second,month,day,year,is_dst)  



    • Write the Inbuilt function that reverses the string.
      strrev(string)



    • Write the Inbuilt Function that converts the string to Uppercase.
    strtoupper(string)  



    • When we can use $REQUEST variable?

    The PHP built-in $_REQUEST function contains the contents of both $_GET, $_POST, and $_COOKIE.
    The $_REQUEST function can be used to collect form data sent with both the GET and POST methods.


    • All variables in PHP starts with a ________ sign symbol. Ans. $
    • _________ is used to print text in php page. - Echo 


      • PHP is server side scripting language because.........(complete the statement)
      You can create dynamic web pages with the PHP scripting language. A dynamic Web page interacts with the user, so that each user visiting the page sees customized information


      • What is an array ? List the types of array.
      An array is a special variable, which can store multiple values in one single variable.
      • Numeric array - An array with a numeric index
      • Associative array - An array where each ID key is associated with a value
      • Multidimensional array - An array containing one or more arrays




      • Explain for loop with example.

      The for loop is used when you know in advance how many times the script should run.

      Syntax

      for (init; condition; increment)
        {
        code to be executed;
        } 




       
      • Give an example of a function that returns a value.
      • Major difference between include() and require() functions.
      • List 3 different function used to open, close, and checking end-of particular file.
      • Difference between PHP and HTML
      • What is an anchor tag?
      • How can we add image in HTML document?