Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Day 1 - Getting Started - Become PHP Expert in 30 days

  1. #1
    Join Date
    Sep 2003
    Posts
    3,040

    Default Day 1 - Getting Started - Become PHP Expert in 30 days

    Getting Started - Become PHP Expert in 30 days.



    What is PHP

    PHP is a programming language, created for web development.

    Who Use PHP

    Facebook, Yahoo, Wikipedia, Flickr, SourceForge, Photobucket and many other large sites use PHP.

    Lets Say Hello to PHP

    This is your first PHP program.

    Create a file

    hello.php

    Paste following content to that file.

    PHP Code:
    <?php

    echo "Hello from PHP";
    This is very basic PHP program. Upload it to web site (or local web server), access it with url

    http://yoursite/hello.php

    In this program, we use one PHP command (programmers call these commands functions) echo. echo function is used to display text. Try changing the text and see how it works.

    Find

    PHP Code:
    echo "Hello from PHP"

    Replace with

    PHP Code:
    echo "I am a PHP Programmer now"
    or

    PHP Code:
    echo "I have 10 cats and 2 dogs"

    Exercise

    In PHP each instructions end with semicolon (;).

    Remove ; from end of PHP line, upload the file to web server and see what error you get.



    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  2. #2
    Join Date
    Oct 2003
    Location
    Kochi, Kerala, India
    Posts
    21,389

    Default

    Successfully uploaded my first php file. You can view the same at

    http://php.flashwebhost.com/vineesh/hello.php

    But I didn't get any error after removing the ; from end of the line. My code is:

    Code:
    <?php 
    
    echo "I am becoming a PHP programmer"
    
    ?>

    One more thing I noticed,

    In the code you given in Day 1 Post (here), under the line 'Paste following content to that file.'

    Code:
    <?php
    
    echo "Hello from PHP";
    Seems '?>' missing.

    Is that not compulsory or you missed it?
    Last edited by vineesh; 05-08-2014 at 10:18 AM.

  3. #3
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    As per PHP coding standward, we don't need ending ?>

    From

    http://www.php-fig.org/psr/psr-2/

    The closing ?> tag MUST be omitted from files containing only PHP.
    Quote Originally Posted by vineesh View Post
    But I didn't get any error after removing the ; from end of the line. My code is:
    Look like this is because latest PHP can handle single line PHP code with out ending semicolon. But we will need semicolon as almost every php code have more than one line.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  4. #4
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    Day 1 PHP programming

    http://php.flashwebhost.com/tom/cats.php


    Code:
    <?php 
    echo "<B><h1>I have 10 cats and 2 dogs</h1></B>" ;

  5. #5
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by vineesh View Post
    One more thing I noticed,

    In the code you given in Day 1 Post (here), under the line 'Paste following content to that file.'

    Code:
    <?php
    
    echo "Hello from PHP";
    Seems '?>' missing.

    Is that not compulsory or you missed it?

    As per PHP Coding Style Guide never use ending ?>

    http://www.php-fig.org/psr/psr-2/

    Only use ?> if you want to write non PHP code after PHP Code block ended, for example

    Code:
    <html>
    <body>
    
    <?php
    
    echo "Welcome";
    
    ?>
    
    </body>
    </html>
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  6. #6
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by image View Post
    Day 1 PHP programming

    http://php.flashwebhost.com/tom/cats.php


    Code:
    <?php 
    echo "<B><h1>I have 10 cats and 2 dogs</h1></B>" ;
    Good, we can use signle quote instead of double quote, that is the recommended and faster way. For example

    Code:
    <?php 
    
    echo '<B><h1>I have 10 cats and 2 dogs</h1></B>' ;
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  7. #7
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    Day 1 PHP programming

    http://php.flashwebhost.com/tom/programmer.php

    Code:
    <?php 
    
    
    echo '<I><U><h1>I am a PHP Programmer now</h1></U></I>';

  8. #8
    Join Date
    Sep 2003
    Location
    india
    Posts
    11,527

  9. #9
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    Day 1 PHP programming

    http://php.flashwebhost.com/tom/flashwebhost.php

    Code:
    <?php
    
    
    echo '<h1><b><center>FlashWebHost.com</center></b></h1>' ;
    
    
    echo '<p><a href="http://www.flashwebhost.com">FlashWebHost.com</a> was founded in 2001 and is one of the oldest and most stable web hosting companies in the world. The secret to our long history is the loyalty of our satisfied customers. FlashWebHost.com is a leading provider of high performance, low cost web hosting solutions. We offer a diverse range of flexible products coupled with unrivalled customer care. We only host on reliable servers with an up time in excess of 95%. All of our accounts include instant online set up and access to our unique web based control panel. Whatever your requirements, <a href="http://flashwebhost.com">FlashWebHost</a> has a solution tailored to your needs. We specialise in script hosting like: fantastico webhosting, php mysql hosting, and following softwares: wordpress blog hosting, mambo and joomla hosting, forum, ftp, email and multiple domains hosting. We distinguish ourselves by offering superior customer service Guarantee. We distinguish ourselves by offering superior customer service Guarantee. You\'ll find the FlashWebHost.com team is always friendly, understandable and helpful. </p>';
    Last edited by image; 05-08-2014 at 11:43 AM.

  10. #10
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    Day 1 PHP programming

    http://php.flashwebhost.com/sherly/indian.php

    Code:
    <?php
    
    echo "I am an Indian!";

    Learning PHP





    Last edited by sherlyk; 05-08-2014 at 03:41 PM.

Page 1 of 4 123 ... LastLast

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
  •