You are viewing our Forum Archives. To view or take place in current topics click here.
PHP Tutorial - Part 1 the basics.
Posted:

PHP Tutorial - Part 1 the basics.Posted:

TTG_iKYLE
  • TTG Addict
Status: Offline
Joined: May 12, 201013Year Member
Posts: 2,302
Reputation Power: 230
Status: Offline
Joined: May 12, 201013Year Member
Posts: 2,302
Reputation Power: 230
Okay so i'm going to teach you the basics of php in this thread so lets start off by showing you "PHP Tags"

There are two types of php tags.
One

<?PHP

?>


Two

<?

?>


There is no difference really but I prefer using <?PHP it just looks better and neater and people understand it more if you sell/give them your code.

So now i'm going to show you how to echo out text in php.


<?PHP
   echo"Hello world";
?>


So this will show a white screen whit the text "Hello world". Basic huh?

So now its going to get a bit harder not much but a little.


<?PHP
   echo"<center><b>Hello World</b></center>";
?>


Okay now you will see "Hello World" in bold and in the middle of the screen. This is because you can also enter html in to the echo tags.


<?PHP
   echo"<center><b><a href="http://www.thetechgame.com">Hello World</a></b>                                             </center>";
?>


Oh no! We got a error! This is because in the <a href=""> the " is closing the echo tags. There is a simple way to fix this add a \ in front of it.
So like this.

<?PHP
   echo"<center><b><a href=\"http://www.thetechgame.com\">Hello World</a></b>                                             </center>";
?>


YAY! It works now it says "Hello World" and when you click that it takes you to thetechgame.com.

I will be posting more tutorial about php soon, and I mite even do video tutorials!
#2. Posted:
Nic
  • Retired Staff
Status: Offline
Joined: Jun 08, 201013Year Member
Posts: 2,466
Reputation Power: 1070
Motto: I've been watching you all day.
Motto: I've been watching you all day.
Status: Offline
Joined: Jun 08, 201013Year Member
Posts: 2,466
Reputation Power: 1070
Motto: I've been watching you all day.
Nice to see something other than HTML/CSS for a change. However, try going deeper in the actual PHP. Basics include variables, arrays, operators, conditional statements, loops and functions. This is basically just explaining how to output HTML in PHP. Not to mention using single quotes for the echo function are more suited for printing HTML so you won't have to add backslashes all the time.
#3. Posted:
TTG_iKYLE
  • TTG Addict
Status: Offline
Joined: May 12, 201013Year Member
Posts: 2,302
Reputation Power: 230
Status: Offline
Joined: May 12, 201013Year Member
Posts: 2,302
Reputation Power: 230
Nicasus wrote Nice to see something other than HTML/CSS for a change. However, try going deeper in the actual PHP. Basics include variables, arrays, operators, conditional statements, loops and functions. This is basically just explaining how to output HTML in PHP. Not to mention using single quotes for the echo function are more suited for printing HTML so you won't have to add backslashes all the time.


I did add them but then I though i'd do some video tutorials that would make it much easyer
#4. Posted:
iiLagZz_x
  • Powerhouse
Status: Offline
Joined: Aug 18, 201013Year Member
Posts: 466
Reputation Power: 20
Status: Offline
Joined: Aug 18, 201013Year Member
Posts: 466
Reputation Power: 20
Its good, but you havent explained fully, and it may be hard if the person is a beginner. For example, you refer to echo as a tag. its a function. And the reason most people use <?php instead of <? is because some server configurations do not allow the short tags "<?" in the code.
You also havent explained the purpose of ; which deliminates the end of a task. You could also go into depth of how you can end the php section of code with ?> and place ordinary HTML code around it.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.