KrownMS
Please log in or you cant post!
Remember to Vote!!
KrownMS
Please log in or you cant post!
Remember to Vote!!
KrownMS
Would you like to react to this message? Create an account in a few clicks or log in to continue.

KrownMS

v.83 EXP: 850x Meso: 200x Drop: 3x Remember to vote and donate!
 
Vote!  HomeHome  PortalPortal  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

 

 [Easy] PHP Basics

Go down 
AuthorMessage
Jamie

Jamie


Posts : 7
Join date : 2011-10-24
Age : 29
Location : London, England

[Easy] PHP Basics Empty
PostSubject: [Easy] PHP Basics   [Easy] PHP Basics EmptySun Oct 30, 2011 6:58 pm

<?PHP indicates the start of a section of PHP code,
?> indicates the end of a section of PHP code.
Anything not between <?PHP and ?> is HTML code and anything between them IS PHP code.

-------------------------------------------------------------------

The echo function is PHP code which is used to display HTML code. This is useful for when you need to use the HTML code to do something rather than just display it. I.E a button.

The echo function uses either ' or " to indicate the code between it. Example: echo"Hello"; or echo'Hello';. The ; is to end a statement in PHP, without it the code will give errors.

--------------------------------------------------------------------

A variable is a memory location which can change whilst the code is running, and be used to store data and then display it. These are defined by simply typing $ then the name of the variable then = then the value.

Example, $variable = "Variable";. Defining a variable is also a statement so it needs a ; at the end. Now the variable $variable contains "Variable" inside it, it can then be displayed using "echo $variable;".

---------------------------------------------------------------------

If statements can be useful in PHP, it is where a set of code is only executed when a condition is met with the brackets of the statement. This is started using "IF (condition) {Code to be executed};".

You can also add an else so if the condition is not met it does "ELSE {code to be exectuted};".
Since ELSE is part of the IF statement the ; comes after the else.

You can also use "ELSE IF (condition) {code to be executed};" This will run if the IF condition is not met but the ELSE IF condition is met.

Example, IF ($variable=="Variable") {$variable="True";} ELSE IF ($variable=="Variable") {$variable="True";} ELSE {$variable="?";}; This code will check if $variable is spelt correctly and make it contain "True" or if it is spelt incorrectly $variable stores "False".

---------------------------------------------------------------------

MORE COMING SOON!
Back to top Go down
 
[Easy] PHP Basics
Back to top 
Page 1 of 1
 Similar topics
-
» [Easy] Getting ready for PHP
» [Easy] PHP Operators

Permissions in this forum:You cannot reply to topics in this forum
KrownMS :: KrownMS :: Guides & Tutorials :: Coding, HTML/PHP Tutorials-
Jump to: