Ok Well I am new hear but I have been doing programming for over 10 years. I have been seeing a lot of post about learning php So I'll give some basics of php.
PHP Basics
44
Ok Well I am new hear but I have been doing programming for over 10 years.
I have been seeing a lot of post about learning php So I'll give some basics of php.
first you need a file called for example "index.php"
know for the php file to work you need to put this into it
so thats how you start your php file.
Ok Know we are going to make a basic call in your php file.
To start a basic syntax call it starts with $ sign. to enclose your value you can either use ' ' or " " know lets say your value text is hello it's me we in the word it's has a ' to void that value out you put \ this in front of ' this.
Know at the end of your syntax it has to have this ;
To print this value out you can either use print or echo to show your value out.
Ok so there is a very basic start.
So lets say you want to add a comment in your php file so you can come back to the file and read of what you doing you put this in front of your comment // for example.
Know lets say you have two strings you want to print out in one line this is how you do it. I like to make a new string that combines the 2 values.
So when you combine them after the fist value your going to want to put this behind it . yes the period.
So lets say you want to have a break in the value so it would print out like this
hello it's me
and my name is joe
your syntax would look like this you can see after the . we wrapped some html code in it to break it and inclosed with " " and after that we put another . so thats how we do that
Ok wel lets say that if value of some syntax is ted or joe and you want to print out the right value we can do this with the if statement. know the if statement looks like this
In these () is where your going want to put the value that either is equal or not equal to the value equal value is == not equal is =! so lets say value $a == '1' or in word terms this says $a is equal to 1. $a =! '1' word terms this says $a is not equal to 1.
this how it would look in the if statement
the equal
the not equal
Know you see { } these that where you are going to put the data of what you want to show if the value is either equal or not equal.
lets put this in our hello php file
So I hopping your getting it so far
Know with the if statement you can have a else statement with it .
What that means in word terms is this if $a is not equal to 1 else use the other option.
so the php code would look like this
You can also have a if elseif else Statement
hear is a example:
There is also another way you can do this Its called a switch where you add more values with out it becoming a head ache.So to call the switch it switch know case is the value you want it equal to break means it goes to the next one to find if equal to. You have a default if none of the values are equal to any of the case. So hear is a example of it
There some basics of php I hope that this helps
I have been seeing a lot of post about learning php So I'll give some basics of php.
first you need a file called for example "index.php"
know for the php file to work you need to put this into it
PHP Code:
<?php
?> Ok Know we are going to make a basic call in your php file.
To start a basic syntax call it starts with $ sign. to enclose your value you can either use ' ' or " " know lets say your value text is hello it's me we in the word it's has a ' to void that value out you put \ this in front of ' this.
Know at the end of your syntax it has to have this ;
To print this value out you can either use print or echo to show your value out.
PHP Code:
<?php
$hello = 'hello it\'s me';
echo $hello;
print $hello;
?> So lets say you want to add a comment in your php file so you can come back to the file and read of what you doing you put this in front of your comment // for example.
PHP Code:
<?php
// this is how to print out our syntax
$hello = 'hello it\'s me';
echo $hello;
print $hello;
?> So when you combine them after the fist value your going to want to put this behind it . yes the period.
PHP Code:
<?php
// this is how to print out our syntax
$name = ' and my name is joe';
$hello = 'hello it\'s me';
$hello_name = $hello.$name;
print $hello_name;
?> hello it's me
and my name is joe
your syntax would look like this you can see after the . we wrapped some html code in it to break it and inclosed with " " and after that we put another . so thats how we do that
PHP Code:
<?php
// this is how to print out our syntax
$name = 'and my name is joe';
$hello = 'hello it\'s me';
$hello_name = $hello."<br>".$name;
print $hello_name;
?> PHP Code:
if(){
}
this how it would look in the if statement
the equal
PHP Code:
if($a == '1'){
}
PHP Code:
if($a =! '1'){
}
PHP Code:
<?php
$a = '1';
if($a == '1'){
$b = 'what i want to print if $a is equal to 1';
}
print $b;
?> PHP Code:
<?php
// this is how to print out our syntax
$diff_name = 'ted';
if($diff_name == 'ted'){
$user ='Ted';
}
if($diff_name == 'joe'){
$user ='Joe';
}
$name = 'and my name is '.$user;
$hello = 'hello it\'s me';
$hello_name = $hello."<br>".$name;
print $hello_name;
?> Know with the if statement you can have a else statement with it .
What that means in word terms is this if $a is not equal to 1 else use the other option.
so the php code would look like this
PHP Code:
<?php
$a = '1';
if($a == '1'){
$b = 'what i want to print if $a is equal to 1';
}else{
$b = 'what i want to print if $a is not equal to 1';
}
print $b;
?> hear is a example:
PHP Code:
<?php
// this is how to print out our syntax
$diff_name = 'ted';
if ($diff_name == 'ted'){
$user ='Ted';
} elseif ($diff_name == 'joe'){
$user ='Joe';
}else{
$user ='Noname';
}
$name = 'and my name is '.$user;
$hello = 'hello it\'s me';
$hello_name = $hello."<br>".$name;
print $hello_name;
?> PHP Code:
<?php
// this is how to print out our syntax
$diff_name = 'ted';
switch ($diff_name){
case 'ted':
$user ='Ted';
break;
case 'joe':
$user ='Joe';
break;
case 'erica':
$user ='Erica';
break;
default:
$user ='Noname';
}
$name = 'and my name is '.$user;
$hello = 'hello it\'s me';
$hello_name = $hello."<br>".$name;
print $hello_name;
?> - Anoosh Kashefi
- anna14
- teguhyuliantos
- [1] reply
- jiffyspop
- OrlandoBloom
- Johnsena Banned
- rising_sun Banned
- cutegirl36
- advocatekabir
- dylanrodriguez2012 Banned
- [ 1 ] Thanks
- [1] reply
- phpguy900
- kaizen
- [ 1 ] Thanks
- [1] reply
- madelinekim
- Mr Bill
- happy0611 Banned
- Ice Berg Banned
- James Andy
- John Ayling
- [1] reply
- Carl Potts
- weaveronline
- crodev Banned
- jaasmit
- [1] reply
- annahussy
- nikowe Banned
- avjy27
- rahul1122 Banned
- ricta
- michaelh73
- sham2
- sham2
- genanovlis
- icando
- [2] replies
- Bernardcwood
- jasonallvall
- jasonallvall
- HowardBeck
- jaasmit
- princysharma1990 Banned
- Simon Marco
- mmrumii
- ubaid12j
- dmg68
- bhushan@rancor
- juliarose
- davidc1
- Nauman K
- [1] reply
- DeskCoder
- Feellalingnom Banned
Next Topics on Trending Feed
-
44