Results 1 to 6 of 6

Thread: What are PHP arrays, PHP cookies and PHP Files?

  1. #1
    Join Date
    Nov 2009
    Posts
    68

    What are PHP arrays, PHP cookies and PHP Files?

    I am looking forward to learn PHP- Hypertext Preprocessor for server side scripting. But before starting with it I need help to understand following concepts of PHP.
    1. What are PHP Arrays?
    2. What are PHP Cookies?
    3. What PHP Files contain?

    Please provide some valid information on the above topics as well as provide some examples.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    PHP File

    Similar to ASP(Active Server Pages), PHP is also a scripting language on the Server side. Thus the scripts in PHP are to be processed on the server side. The PHP files contain HTML tags, the scripts and the text as well. Thus, the PHP files are submitted as plain HTML to the browser.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Arrays in PHP

    PHP supports three different types of arrays:
    • The Associative array,
    • The Numeric array and
    • The Multidimensional array.

    As the basic definition of arrays in any programming language it is used to hold multiple values all stored in a single array variable.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Cookies in PHP

    Cookie is a file stored on the host(client) machine by the server to identify the user when the user visits that web site. For PHP we can create and set the cookie using the setcookie() function. The syntax of the setcookie() is as follows:
    setcookie(name, value, expire, path, domain);
    eg:
    Code:
    setcookie("host", "Adam", time()+7200);

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Associative Arrays of PHP

    For an Associative array of PHP value is associated to every ID Key. The very main characteristic of Associative array is that it allows the programmer to use values as keys.Thus, permitting the programmers to assign values to them.
    Code:
    $sal = array("Ram"=>10000, "Ravi"=>15000, "Clint"=12000);
    The above line of code is used to assign salary.

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    PHP Cookies

    Code:
    <html>
    <body>
    
    <?php
    if (isset($_COOKIE["client"]))
      echo "Hello " . $_COOKIE["user"] . "!<br />";
    else
      echo "Hello Client!<br />";
    ?>
    
    </body>
    </html>
    The above PHP code is useful in finding if the cookie is set or not. For this purpose we can make use of the isset() function. You can also delete a cookie in the following manner:
    Code:
    <?php
    setcookie("client", "", time()-1800);
    ?>

Similar Threads

  1. Replies: 10
    Last Post: 07-03-2012, 09:41 AM
  2. After setting cookies to "Never" Safari accepts all cookies anyway
    By Padmasola in forum Technology & Internet
    Replies: 7
    Last Post: 02-03-2012, 10:27 AM
  3. Google cookies does not obeys the cookies in Opera 10.51
    By Wild Kat in forum Technology & Internet
    Replies: 3
    Last Post: 26-02-2012, 01:54 PM
  4. Replies: 7
    Last Post: 21-01-2012, 07:11 PM
  5. Where is my temp files folder & cookies folder?
    By aftab1 in forum Operating Systems
    Replies: 2
    Last Post: 05-11-2008, 12:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,257,170.86596 seconds with 17 queries