Jump to content


Photo

PHP Coding Tutorial 1


  • Please log in to reply
2 replies to this topic

#1 Elric

Elric

    Designer

  • Hosted
  • 2,857 posts
  • Projects:Middle-Earth Expanded
  •  Coder
  • Donated

Posted 01 April 2012 - 03:24 AM

PHP is a widely used coding language. It is used to create websites and contact forms.

To start off are PHP tutorial we will start by making a very simple “Hello World!” script.
So, open up notepad++ and create a new page. Type the following:

<?php
echo "Hello World!”;
?>

Press save as and save it as “Tutorial 1 - Hello World!.php” save it to this directory: “(drive letter where you installed xampp):\xampp\htdocs\tutorials”.

Make sure xampp is open and apache and MySQL are running. Go to your web browser and type: localhost:2375/tutorials or localhost:80/tutorials depending on which you have and press enter. Then click “Tutorial 1 - Hello World!.php” and watch Hello World! be in your web browser! Now let’s go over what we told PHP to do.

The: <?php and the ?> are the tags that every PHP form start and end with. So, get used to typing it in!
echo “Hello World!”; tells PHP to echo out Hello World! in the web browser.

If you type this code in:

<?php
echo "Hello World!”;
echo "Hello World!”;

?>

And save it, and refresh your webpage it will show as Hello World!Hello World! because there is no break. A break is a basic html code that puts text onto different lines. To do this all we have to do is add:

<?php
echo "Hello World!”; ‘<br>’
echo "Hello World!”;

?>

See the difference? I added ‘<br>’. That’s it! This is the end of the first tutorial. The second tutorial should be available in a few days.

Edited by {IP}Apollo, 09 April 2012 - 08:12 PM.


#2 Hostile

Hostile

    Benefitting Humanity Simply by Showing Up!

  • Veterans
  • 9,551 posts
  • Location:Washington DC
  •  T3A Founder
  • Division:Revora
  • Job:Global Administrator
  • Donated
  • Association

Posted 01 April 2012 - 05:25 AM

I wouldn't recommend using echo to include html but that's just my opinion.
<?php
echo "Hello World!";
?>
<br />
<?php
echo "Hello World!";
?>
It makes it easier for coding programs such as Dreamweaver which color codes languages.

I once had to edit a php site that used echo for the entire table layout. :(

#3 Elric

Elric

    Designer

  • Hosted
  • 2,857 posts
  • Projects:Middle-Earth Expanded
  •  Coder
  • Donated

Posted 01 April 2012 - 02:51 PM

Ya.... I see where your coming from but i learned it the way i showed above so..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users