Let's Learn PHP Together

Discussion in 'PHP' started by maestroweb, Mar 8, 2008.

  1. #1
    I hope we can share each other and learn syntax for every scripts in php programming.

    Basic PHP Syntax

    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 ?>.

    However, for maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.

    <?php
    
    ?>
    Code (markup):
    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:

    <html>
    <body>
    
    <?php
    echo "Hello World";
    ?>
    
    </body>
    </html>
    Code (markup):
    Try to find out in your browser localhost or upload to your hosting support php
     
    maestroweb, Mar 8, 2008 IP
  2. maestroweb

    maestroweb Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What You Should Already Know

    Before you continue you should have a basic understanding of the following:

    * HTML / XHTML
    * Some scripting knowledge

    What is PHP?

    * PHP stands for PHP: Hypertext Preprocessor
    * PHP is a server-side scripting language, like ASP
    * PHP scripts are executed on the server
    * PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
    * PHP is an open source software (OSS)
    * PHP is free to download and use

    What is a PHP File?

    * PHP files may contain text, HTML tags and scripts
    * PHP files are returned to the browser as plain HTML
    * PHP files have a file extension of ".php", ".php3", or ".phtml"

    What is MySQL?

    * MySQL is a database server
    * MySQL is ideal for both small and large applications
    * MySQL supports standard SQL
    * MySQL compiles on a number of platforms
    * MySQL is free to download and use

    PHP + MySQL

    * PHP combined with MySQL are cross-platform (means that you can develop in Windows and serve on a Unix platform)

    Why PHP?

    * PHP runs on different platforms (Windows, Linux, Unix, etc.)
    * PHP is compatible with almost all servers used today (Apache, IIS, etc.)
    * PHP is FREE to download from the official PHP resource: php dot net
    * PHP is easy to learn and runs efficiently on the server side

    Where to Start?

    * Install an Apache server on a Windows or Linux machine
    * Install PHP on a Windows or Linux machine
    * Install MySQL on a Windows or Linux machine
     
    maestroweb, Mar 8, 2008 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    I give you a week. :p

    Probably even less.
     
    nico_swd, Mar 8, 2008 IP
  4. maestroweb

    maestroweb Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Variables in PHP

    Variables are used for storing a values, like text strings, numbers or arrays.

    When a variable is set it can be used over and over again in your script

    All variables in PHP start with a $ sign symbol.

    The correct way of setting a variable in PHP:

    New PHP programmers often forget the $ sign at the beginning of the variable. In that case it will not work.

    Let's try creating a variable with a string, and a variable with a number:

     
    maestroweb, Mar 8, 2008 IP
  5. maestroweb

    maestroweb Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Let's try to know how to combine php with html.
    We want to build form contact for sample :


    PHP Form Handling

    The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.

    Form example:

    The example HTML page above contains two input fields and a submit button. When the user fills in this form and click on the submit button, the form data is sent to the "welcome.php" file.

    The "welcome.php" file looks like this:

    A sample output of the above script may be:

    Welcome John.
    You are 28 years old.


    simple don't you.... :)

    For continue study and learn more just goto this site :
    
    http://www.w3schools.com/php/
    Code (markup):
    It will help you to find more scripts and learn
     
    maestroweb, Mar 8, 2008 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    nico_swd, Mar 8, 2008 IP
  7. maestroweb

    maestroweb Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i just want to share.... sorry if i was wrong nico
     
    maestroweb, Mar 8, 2008 IP
  8. maestroweb

    maestroweb Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    okay so we going on and continue learn php.

    You can learn alone or you can learn together with me :

    will show in your browser as : 2008-03-09

    it's easy to learn php :)

    try to look at this :

    2008-03-09
    Tomorrow is 2008/03/10

    this is the syntax :
     
    maestroweb, Mar 8, 2008 IP
  9. maestroweb

    maestroweb Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    For continue study and learn more just goto this site :
    or you can go to uncle google and type learn syntax php

    
    http://www.w3schools.com/php/
    Code (markup):
    It will help you to find more scripts and learn
     
    maestroweb, Mar 8, 2008 IP