Learn the Basics of Php (works)
Intro: Learn the Basics of Php (works)
in this instructable ill show you how to:
setup a local web server
code some php
setup a local web server
code some php
STEP 1: You Will Need
STEP 2: Xampp
folow this tutorial on how to set up xampp
(if you want me to post one in text just comment bellow)
(if you want me to post one in text just comment bellow)
STEP 3: Echo and Print
all the php you write will be inbetween this
?>
lets start by saying something to do this we use echo.
ok here we go
echo "this is text";
?>
so whats this mean? ill do a brack down
echo
tells the computer to say something
"
tells the computer the string has started
";
tells the computer the string has ended.
?>
lets start by saying something to do this we use echo.
ok here we go
echo "this is text";
?>
so whats this mean? ill do a brack down
echo
tells the computer to say something
"
tells the computer the string has started
";
tells the computer the string has ended.
STEP 4: Variabels
what are variabals?
there like cut and past but in php
so whats the point of that
say there was some song string that you used alot like
this is a looooooooooooooooooooooooooooooooong string.
and you dont want to type that every time you want to say it then you would use a variabal. but how? with ease. here:
<?
$long = "this is a looooooooooooooooooooooooooooooooong string.";
print $long
?>
you can also put strings together with a
.
heres how
<?
$str1 = "this is my first string. this is my";
$str2 = "second string.";
echo " $str1.$str2";
?>
put what if i want to say something with $ or "" in it?
use a \.
heres how
<?
echo "Liam said \"the his name is Liam too \"
echo "we will have to charge him \$10";
?>
there like cut and past but in php
so whats the point of that
say there was some song string that you used alot like
this is a looooooooooooooooooooooooooooooooong string.
and you dont want to type that every time you want to say it then you would use a variabal. but how? with ease. here:
<?
$long = "this is a looooooooooooooooooooooooooooooooong string.";
print $long
?>
you can also put strings together with a
.
heres how
<?
$str1 = "this is my first string. this is my";
$str2 = "second string.";
echo " $str1.$str2";
?>
put what if i want to say something with $ or "" in it?
use a \.
heres how
<?
echo "Liam said \"the his name is Liam too \"
echo "we will have to charge him \$10";
?>
STEP 5: Php Can Do Math
php can do math!
but how?
just follow along!
say i wanted to add 5 and 5 together then i go
<?
str= 5+5;
print "$str";
?>
this will output
10
so now lets to some more advanced math
<?
str=(5.5+4.5)*500+(2*10);
print "$str";
?>
here is a key
add = +
take away = -
divide = /
multiply = *
but how?
just follow along!
say i wanted to add 5 and 5 together then i go
<?
str= 5+5;
print "$str";
?>
this will output
10
so now lets to some more advanced math
<?
str=(5.5+4.5)*500+(2*10);
print "$str";
?>
here is a key
add = +
take away = -
divide = /
multiply = *
7 Comments
NickS21 8 years ago
codeacademy and treehouse by far is my choice.
TanveerA 9 years ago
I suggest Ptutorial for all the world you would like laptop
committal to writing wise, they're sensible. For more infomation visit: http://www.ptutorial.com
shikaku 15 years ago
backcountry 15 years ago
http://w3schools.com
liammk 15 years ago
snoyes 15 years ago
Step 3 - The difference between 'echo' and 'print' has little to do with HTML. See http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40
Step 4 - Check your spelling. More importantly, use a backslash to escape characters in a string (you show a forward slash). The example showing concatenation with the "." operator should not use quotes
Step 5 - The 'str' variable is missing its $ in the assignment. You have also put the operation in quotes, so the variable would contain the literal string "5+5", and not the result of the operation. Remove the quotes.
liammk 15 years ago