[Tutorial] PHP Basics - Variables & Output
#1

In this tutorial i will be teaching you the basics of the PHP programming language, i bet your thinking most of us know the basics why teach? well its so incase new people join that don't know what a variable is so lets begin

What i will be teaching is - Variables

PHP код:
<?php
$test 
"hai";
echo 
$test
?>
That there is a variable. Well i bet your asking what does it do?? well it will echo (show something) so if it echos the variable test it will show the text in the "" so in this case it is "hai" that is a basic output (echo) and a variable ($test)

now if you wanted to output a number so like this

PHP код:
<?php
$tutorial 
22;   // (Notice i didnt put it in some "" thats what you do with numbers there isnt any need for"")
echo $tutorial
?>
The $ sign declares the variable its a bit like the Dim in VB programming you cant have a Variable without it What the semicolon ";" does is it ends the line of code your working with so E.G
PHP код:
echo "Test"
if i don't end that line of code php will just keep reading it so its needed if you have several lines of code. Now i bet your saying yo assho*le what is a variable well a variable is just something that stores information, data ETC so like this
PHP код:
$SimonCowell "Retard"// Now this is information (A FACT) now the variable $SimonCowell will store his name which we know is a fact for to be used in other codes.
echo "HE IS A FAG"
I hope i helped some people and i will be doing more tuts

Please don't go hating please i am not that good with Tutorials i tried my best that's all i can do - but my coding is top notch
Reply
#2

May I ask how this relates to sa-mp scripting?

Also, what is the point of

PHP код:
$SimonCowell "Retard"// Now this is information (A FACT) now the variable $SimonCowell will store his name which we know is a fact for to be used in other codes. 

echo "HE IS A FAG"
That will just print HE IS A FAG not the variable. You should tell us how to insert variables into strings such as

PHP код:
$SimonCowell "SimonCowell"// Now this is information (A FACT) now the variable $SimonCowell will store his name which we know is a fact for to be used in other codes. 

echo "$SimonCowell HE IS A FAG"
Reply
#3

PHP код:
$SimonCowell "Retard"
echo 
"The ".SimonCowell." isn't cool"."<br/>"
Another way
Reply
#4

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
PHP код:
$SimonCowell "Retard"
echo 
"The ".SimonCowell." isn't cool"."<br/>"
Another way
You are missing the $ sign on the echo line.
Reply
#5

This isn't really related to SA:MP. But ok.
Reply
#6

Still nice he trying to help members that can't code PHP well learn a bit.
Reply
#7

Quote:
Originally Posted by robintjeh
Посмотреть сообщение
Still nice he trying to help members that can't code PHP well learn a bit.
what are u on about the php code is correct (but i did it in 5 mins because of school)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)