1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Beginners Guide for PHP

Discussion in 'PHP' started by roopajyothi, Apr 25, 2010.

  1. #1
    As we all know that Programming in PHP is fun and easy. It is a very powerful scripting language that takes simple HTML and turns it into a fully-interactive experience for the web user. Let's get started!

    Note: These tutorials assume that you have a working web server that's capable of displaying PHP code and that you have PHP installed on that web server system or that you're using a server that is equipped and ready.
    You can run PHP on Windows. You can even use PHP with IIS (The Windows Web Server) so you don't necessarily need Unix/Linux and Apache.

    PHP Reference

    Your best reference for all things PHP is the PHP web site: www.php.net. Go there and bookmark it--you'll refer to it often.

    PHP Speaks HTML

    The first thing you have to learn and always remember is that if you use even one line of PHP code in an HTML file, you must name the file with a .php extension. The .php extension tells the web server that this file is special and needs special handling by the PHP executable and related libraries.

    Delimit Your PHP

    Second, all PHP functions and code must be inserted between the following delimiters

    PHP Syntax

    --the less than question mark opens the code and the question mark greater than close. You must always use delimiters in pairs--an opening delimiter and closing delimiter. Delimiters are symbols that tell the web server what kind of content follows and how it should be handled. HTML uses delimiters too

    PHP Syntax


    .

    Example 1: How About a Date?

    If you want to add the current date to a web page, the code would look like:


    Explanation: The 'echo' command tells the PHP program to echo the results that follow to the screen. Since you're using HTML and the browser is your "screen", that's where you see the results. The date function is a built-in PHP program that display the date in the format you specify in the parentheses.

    Save the file with the filename, test.php.

    Open the file by pointing your browser to the file on the webserver and you should see:

    Jan-19-2009 (you'll see the current date)

    Try changing the date format by moving things around ("d-M-Y") or just using one of the date variables ("Y"). Refer to the PHP documentation to get a full range of date variables. It's fun and useful.

    The full list of PHP date-related functions are here.

    Example 2: Who's Looking at You, Kid?

    If you want to gather some info about the people that are looking at your site or if you just want to let them know you're watching, you can easily echo some of their information back to them by using what's known as Server Variables.

    Note: This is not personal information, nor are you stealing anything from them. It is information that is transferred to your website when a visitor connects to your webpages.

    You can get their IP Address and their Browser and Computer information. The IP Address is how computers communicate with each other on the Internet--think of it as kind of like a phone number or home address.

    To see this information, edit your test.php file again and enter the following:


    PHP Syntax
    Explanation: The line


    is HTML for start a new Paragraph. The next line,

    echo "Your IP Address is " . $_SERVER['REMOTE_ADDR'];
    sends the text, "Your IP Address is " to your browser. The dot (.) is PHP for concatenate or connect these two things. $SERVER['REMOTE_ADDR'] is a built-in Server variable that echoes the viewing browser's IP Address to their browser.

    Save this file and point your browser to test.php.

    You should see:

    Jan-19-2009 (Current Date)

    Your IP Address is 10.0.1.200 (The IP Address of Your Computer)

    There are several variables from which to choose here. The complete list is located at: PHP:$_SERVER.

    Change the Server variable or add new ones. For starters, try: HTTP_USER_AGENT to see your browser and computer information.

    Stay tuned for PHP Tutorial Part Two: Combining HTML and PHP where you'll get a taste of how to integrate these two languages in a more elegant fashion. Don't worry, it's easy and you'll like the way it works. It's easier to read and more fun to write.

    Some Suggested Site for PHP Learning:


    http://www.w3schools.com/php/default.asp
    http://learnphp.org
    http://www.tizag.com/phpT/
    http://www.learnphponline.com/
    http://www.php-learn-it.com/
    http://www.killerphp.com/videos/
    http://www.tuxradar.com/practicalphp

    Will Continue this series if i get support from you friends!
    SEMrush
     
    Last edited: Apr 25, 2010
    roopajyothi, Apr 25, 2010 IP
    SEMrush
  2. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #2
    Any Comments please??
     
    roopajyothi, Apr 26, 2010 IP
  3. Bohra

    Bohra Prominent Member

    Messages:
    12,579
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #3
    too basic but nice work as it seems u took the efforts to write it ;)
     
    Bohra, Apr 26, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Thanks a lot! :)
     
    roopajyothi, Apr 26, 2010 IP
  5. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Thanks for your Support!
    Will add more soon :)
     
    roopajyothi, Apr 29, 2010 IP
  6. SunShellNET

    SunShellNET Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi
    A little intro to php functions is appreciated
     
    SunShellNET, Apr 29, 2010 IP
  7. khajeya

    khajeya Member

    Messages:
    256
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #7
    i appreciated it, but still waiting for your next tutorial :) thank you
     
    khajeya, Apr 30, 2010 IP
  8. Nakbali

    Nakbali Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    thanks for the info, it's very usefull for newbie php progrsmming like me, :D
     
    Nakbali, Apr 30, 2010 IP
  9. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #9
    Will update this soon :)
     
    roopajyothi, May 9, 2010 IP
  10. swashata

    swashata Member

    Messages:
    86
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #10
    Very informative thread for the beginners! Keep up the good work :)
     
    swashata, May 13, 2010 IP
  11. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #11
    Welcome! Will Put a tutorial on syntax first!
     
    roopajyothi, May 13, 2010 IP
  12. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #12
    A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document.

    On servers with shorthand support enabled you can start a scripting block with <? and end with ?>.

    For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.
    A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.

    Below, we have an example of a simple PHP script which sends the text "Hello World" to the browser:
    Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.

    There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".

    Note: The file must have a .php extension. If the file has a .html extension, the PHP code will not be executed.
     
    roopajyothi, May 13, 2010 IP
  13. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #13
    roopajyothi, May 21, 2010 IP
  14. webmaster365

    webmaster365 Greenhorn

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #14
    Why you are working too hard
     
    webmaster365, Jun 2, 2010 IP
  15. phpwnes

    phpwnes Peon

    Messages:
    509
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #15
    thanks for the tutorials i already knew of some of those sites but also there other ones are a great source to improve my php skills and welcome to California:)
     
    phpwnes, Jun 2, 2010 IP
  16. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #16
    roopajyothi, Jun 2, 2010 IP
  17. modheavymod

    modheavymod Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Thank you Roopajyothi. I'm just studying
     
    modheavymod, Jun 4, 2010 IP
  18. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #18
    Welcome!
    Just added this stuffs for newbie's :)
    All the Best
     
    roopajyothi, Jun 4, 2010 IP
  19. johny321

    johny321 Member

    Messages:
    293
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #19
    Thanks for providing really nice stuff
     
    johny321, Jun 4, 2010 IP
  20. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #20
    Oops! Welcome for that if really helps you!
    if you need more about particular resource don't forgot to request here
     
    roopajyothi, Jun 4, 2010 IP