You are viewing our Forum Archives. To view or take place in current topics click here.
PHP Tutorials - 1
Posted:
PHP Tutorials - 1Posted:
Status: Offline
Joined: Dec 18, 201112Year Member
Posts: 33
Reputation Power: 1
Status: Offline
Joined: Dec 18, 201112Year Member
Posts: 33
Reputation Power: 1
Basically if you know any HTML, it's a great start to PHP
First off there are 4 tags;
Traditionally they're
Or you can use short tags
But to use short tags you mus activate them through configurations
Quick Echo
If you want to display something on your webpage you have to use the echo command
You have to use either a quotation or apostrophe to start and end the string of characters you wish to echo.
Variables
The basic thing you need to know is the "Cash sign", ( $ ) any, and every variable in PHP will be started with this.
If you want to set the variable, you must use the equal sign making it look like this.
As you can see, I set the variable " Chrome " to "is awesome", if you look at the end of my code I have a semi colon. Every command you set in php will need a semi colon to indicate that this or that command is done and you want to move on.
If you're writing code and you want to check if this code is equal to this to proceed on to something else you want to use the double equal sign so you don't accidentally set it to something
IF/Elseif Commands
As you can see in the above demonstration I have the command IF
If is what it's generally used for, like IF jimmy is red then call him a jew.
Elseif is used after an if statement, as in, if the first statement didn't work, give it an alternative it can look to. And lastly the ELSE command is the last resort to where if the above doesn't work, then just do this.
Example :
Now you can do much more with If/Elseif/Else statements
but a few things to point out, in the statements (if/elseif) you must enclose what you want to compare or whatever in the parentheses, in the else statement you don't need to compare anything as it's a last resort so you just use the curly brackets to enclose the command.
Into the curly brackets, you have to use these because if you don't have them then the code continuously runs into the next command basically **** up your whole code. So remember to use curly brackets.
If you need any help / questions. Post. Suggestions? keep posting
First off there are 4 tags;
Traditionally they're
<?php // ?>
Or you can use short tags
<? ?>
But to use short tags you mus activate them through configurations
Quick Echo
If you want to display something on your webpage you have to use the echo command
<?php echo " yeah i'm cool"; ?>
You have to use either a quotation or apostrophe to start and end the string of characters you wish to echo.
Variables
The basic thing you need to know is the "Cash sign", ( $ ) any, and every variable in PHP will be started with this.
If you want to set the variable, you must use the equal sign making it look like this.
<?php $chrome = "is awesome"; ?>
As you can see, I set the variable " Chrome " to "is awesome", if you look at the end of my code I have a semi colon. Every command you set in php will need a semi colon to indicate that this or that command is done and you want to move on.
If you're writing code and you want to check if this code is equal to this to proceed on to something else you want to use the double equal sign so you don't accidentally set it to something
<?php //adassdfsrandomcodeee if($chrome == 'awesome') { echo " Yeah, he's awesome "; } ?>
IF/Elseif Commands
As you can see in the above demonstration I have the command IF
If is what it's generally used for, like IF jimmy is red then call him a jew.
Elseif is used after an if statement, as in, if the first statement didn't work, give it an alternative it can look to. And lastly the ELSE command is the last resort to where if the above doesn't work, then just do this.
Example :
<?php
$chrome = "***";
if($chrome == "***") {
echo "Chrome's a *** olololol";
}
elseif($chrome == "awesome") {
echo "something's obviously wrong...";
}
else {
echo "Chrome doesn't exist";
}
?>
Now you can do much more with If/Elseif/Else statements
but a few things to point out, in the statements (if/elseif) you must enclose what you want to compare or whatever in the parentheses, in the else statement you don't need to compare anything as it's a last resort so you just use the curly brackets to enclose the command.
Into the curly brackets, you have to use these because if you don't have them then the code continuously runs into the next command basically **** up your whole code. So remember to use curly brackets.
If you need any help / questions. Post. Suggestions? keep posting
You are viewing our Forum Archives. To view or take place in current topics click here.