-
-
Save milapdave/c2d00482179c8853f210b0de62848771 to your computer and use it in GitHub Desktop.
Special Documentation about Basic PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*================================== | |
Basic Introduction of PHP | |
====================================*/ | |
** PHP - Hypertext Preprocessor | |
** Server side scripting language | |
** First Released Date : 1994 | |
** Created By: Rasmus Lerdorf | |
** Most CMS used PHP - | |
* WordPress | |
* Joomla | |
* Drupal | |
** Most popular website used PHP in there website - | |
* Yahoo | |
* Wikipedia | |
* Flicker | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*====================================* | |
Rules for PHP variables: | |
======================================*/ | |
/* | |
=> A variable starts with the $ sign, followed by the name of the variable | |
=> A variable name must start with a letter or the underscore character | |
=> A variable name cannot start with a number | |
=> A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) | |
=> Variable names are case-sensitive ($age and $AGE are two different variables) | |
*/ | |
//PHP variable | |
$myfriend = 'my friend name is jahed hossain'; | |
$br = '<br>'; | |
echo $myfriend . $br; | |
?> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*================================== | |
Operator | |
====================================*/ | |
/* | |
1. Arithmetic Operator | |
2. Assignment Operator | |
3. Logical Operator | |
4. Comparison Operator | |
5. Array Operator | |
6. Increment/decrement Operator | |
7. String Operator | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
======================= | |
1. Arithmetic Operator | |
======================= | |
1.1 - Plus : + | |
1.2 - Mynus : - | |
1.3 - Into : * | |
1.4 - Devided : / | |
1.5 - Modulas : % | |
*/ | |
$father = 60; | |
$son = 25; | |
$plus = $father + $son; //Plus | |
$mynus = $father - $son; //Mynus | |
$into = $father * $son; //Into | |
$devided = $father / $son; //Devided | |
$modulas = $father % $son; //Modulas | |
echo $plus . $br; | |
echo $mynus . $br; | |
echo $into . $br; | |
echo $devided . $br; | |
echo $modulas . $br; | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
======================= | |
2. Assignment Operator | |
======================= | |
2.1 - Plus-equal : += | |
2.2 - Mynus-equal : -= | |
2.3 - Into-equal : *= | |
2.4 - Devided-equal : /= | |
2.5 - Modulas-equal : %= | |
*/ | |
$age = 20; | |
$age = $age += 5; //Plus-equal | |
//$age = $age -= 5; //Mynus-equal | |
//$age = $age *= 5; //Into-equal | |
//$age = $age /= 5; //Devided-equal | |
//$age = $age %= 5; //Modulas-equal | |
echo $age . $br; | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
======================= | |
3. Logical Operator | |
======================= | |
3.1 - (or) - || | |
3.2 - (and) - && | |
3.3 - (not) - ! | |
*/ | |
$username = 'humayunahmed8'; | |
$password = 'ha154248'; | |
// (and) | |
if($username == 'humayunahmed8' && $password == 'ha154248'){ | |
echo 'login success' . $br; | |
}else{ | |
echo 'login failed' . $br; | |
} | |
//(or) | |
/* | |
if($username == 'humayunahmed8d' || $password == 'ha154248'){ | |
echo 'login success'; | |
}else{ | |
echo 'login failed'; | |
} | |
*/ | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
======================= | |
4. Comparison Operator | |
======================= | |
4.1 - (equal) - == | |
4.2 - (not equal) - != | |
4.3 - (not equal) - <> | |
4.4 - (greater than) - > | |
4.5 - (greater than or equal to) - >= | |
4.6 - (less than) - < | |
4.7 - (less than or equal to) - <= | |
*/ | |
$humayun = 20; | |
$jahed = 18; | |
if($humayun > $jahed){ | |
echo 'true' . $br; | |
}else{ | |
echo 'false' . $br; | |
} | |
$humayra = 17; | |
if($humayra >= 18){ | |
echo 'Ready for marriage' . $br; | |
}else{ | |
echo 'not ready for marriage' . $br; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
======================= | |
5. Array Operator | |
======================= | |
5.1 - Indexed Array | |
5.2 - Associative Array | |
5.3 - Multidimensional Array | |
*/ | |
// 5.1 - Indexed Array | |
$father = array(1=>'humayun','foysal','fariya'); | |
//print_r($father); | |
echo $father[1] . $br; | |
// 5.2 - Associative Array | |
$mother = array('humayun'=>21,'foysal'=>18,'fariya'=>10); | |
//print_r($mother); | |
echo $mother['foysal'] . $br; | |
// 5.3 - Multidimensional Array | |
$humayun = array( | |
'humayra' => array( | |
'class' => 12, | |
'group' => 'Business Studies', | |
'hobby' => 'Reading', | |
), | |
'abrar' => array( | |
'class' => 10, | |
'group' => 'Science', | |
'hobby' => 'Sleeping', | |
) , | |
'jahanara' => array( | |
'class' => 9, | |
'group' => 'Humanities', | |
'hobby' => 'Singing', | |
) | |
); | |
//print_r($humayun); | |
//echo $humayun['humayra']['hobby']; | |
//echo $humayun['abrar']['group']; | |
//echo $humayun['jahanara']['class']; | |
echo $humayun['humayra']['hobby'].$br.$humayun['abrar']['group'].$br.$humayun['jahanara']['class'] . $br; | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
============== | |
Loop | |
============== | |
1. for loop | |
2. while loop | |
3. foreach loop | |
*/ | |
//1. for loop | |
//for(initialization,condition,increment/decrement); | |
for($i=100;$i>=1;$i--){ | |
echo $i . $br; | |
} | |
//1++ | |
for($b=1;$b<=100;$b++){ | |
echo $b . $br; | |
} | |
//2+2=4+2=6+2=8 | |
for($b=2;$b<=100;$b+=2){ // assign | |
echo $b . $br; | |
} | |
//1+2=3+2=5+2=7 | |
for($b=1;$b<=100;$b+=2){ // assign | |
echo $b . $br; | |
} | |
//2. while loop | |
$n=1; | |
while($n<=100){ | |
echo $n . $br; | |
$n++; | |
} | |
//3. foreach loop | |
$rahman = array('ramim'=>20,'nadim'=>25,'hridoy'=>30,'sakib'=>28); | |
foreach($rahman as $child=>$year){ | |
//echo $child . $year . $br ; | |
echo $child . ' age is' . $year . $br; | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment