+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: My first PHP script :)

  1. #1
    Symbian.Ankit is offline x10Hosting Member Symbian.Ankit is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    India
    Posts
    12

    Talking My first PHP script :)

    Hi all

    I am a newbie to learning php but will complete it soon
    I am learning from SAMS TEACH YOURSELF PHP IN 10 MINUTES + Programmers Introduction to php4.

    I hope you will help me all:lockd:

    Thanks in advance

    So here is my first php script.Please point out the mistakes if any

    <html>
    <body>
    <?php
    echo today date is ('j H Y');
    echo and time is;
    echo ('H:i:s');
    ?>
    </body>
    </html>


    Can anyone tell me the difference between single quoted(' ') and double quoted strings (" ").Please help me.

  2. #2
    kajasweb's Avatar
    kajasweb is offline Lord Of The Keys kajasweb is an unknown quantity at this point
    Join Date
    Aug 2007
    Location
    Chennai, India
    Posts
    1,722

    Re: My first PHP script :)

    The code must be
    Code:
    <html>
    <body>
    <?php
    echo "today date is " . date('j H Y');
    echo "and time is";
    echo date('H:i:s');
    ?>
    </body>
    </html>
    I think... Single quotes and double quotes are just same. But, they can't be mixed.
    Last edited by kajasweb; 02-18-2008 at 06:03 AM.
    R. Kaja Mohideen
    Start Your Own Blog... Start Making Money...
    http://www.MyiStop.com/
    CuteCom.Net - Low Cost International Internet Telephony (VoIP) Service

  3. #3
    Symbian.Ankit is offline x10Hosting Member Symbian.Ankit is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    India
    Posts
    12

    Re: My first PHP script :)

    thanks webmaster .thanks for correction.

  4. #4
    MaestroFX1's Avatar
    MaestroFX1 is offline Community Advocate MaestroFX1 has a spectacular aura about
    Join Date
    Feb 2008
    Location
    Area 51
    Posts
    1,577

    Re: My first PHP script :)

    Good book for learning PHP but check for PHP 5.

  5. #5
    DarkDragonLord's Avatar
    DarkDragonLord is offline x10 Elder DarkDragonLord is an unknown quantity at this point
    Join Date
    Mar 2007
    Location
    Brazil
    Posts
    782

    Re: My first PHP script :)

    Better you start learning PHP5, since 4 is already out dated and soon they will release PHP6.

    Btw, dunno where i read that but, i think double quotes are more strict... O.o~ Well, i always use double quotes ... just single when is to parse something, like $_GET['blablabla']
    Regards,
    Raphael DDL

    Designing Solutions for You
    *Web Design;
    *Coding;
    Free Downloads;
    and all related Stuff
    .


    My Tutorials:
    | Multi-Language Websites | Rotative Banners |
    | Bookmark Script for All Browsers
    |
    |
    PHP Switching/Including Content|
    |


  6. #6
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: My first PHP script :)

    You must use single ' if the sentence contains a " and " if it contains ' if you don't escape them. I suggest escaping such things. Otherwise I don't think there is any differens

  7. #7
    mmyers is offline x10Hosting Member mmyers is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    7

    Re: My first PHP script :)

    For your example, there's no significant difference, but when you're working with variables in php there is.

    PHP evaluates variables enclosed in double quotes:

    <?php
    $thing="this car";

    echo "I need to buy $thing.";
    ?>
    Displays: I need to buy this car.

    When you use single quotes, the variable isn't evaluated:
    <?php
    $thing="this car";

    echo 'I need to buy $thing.';
    ?>
    Displays: I need to buy $thing.

    Cheers and good luck with your work.

  8. #8
    Franc0 is offline x10 Sophmore Franc0 is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    206

    Re: My first PHP script :)

    double quates are literal.. for example..


    echo date('H:i:s'); WILL DISPLAY DATE IN THAT FORMAT

    echo date("H:i:s"); WILL LITERALLY DISPLAY "H:i:s"
    Hey If i helped you, you can also help me clicking the blue icon to give me some reputation, thanks!;)

  9. #9
    Brandon's Avatar
    Brandon is offline Former Senior Account Rep Brandon is on a distinguished road
    Join Date
    Jun 2006
    Location
    Tewksbury, MA
    Posts
    9,589

    Re: My first PHP script :)

    PHP 5.3 is coming before PHP 6, 5.3 will introduce new features coming in PHP6. You might want to wait a bit before learning;).
    Thanks,
    Brandon Long

  10. #10
    oiwio is offline x10 Sophmore oiwio is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    214

    Re: My first PHP script :)

    also, when having a variable = another variable, you dont need quotes as long as its that variable itself or +, -, *, or / by a number

    http://alchemistrpg.com: This site is worth

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  2. Replies: 8
    Last Post: 12-03-2007, 04:12 PM
  3. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers