Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Variable, string, integer, float.
- echo'<h3> Variable, string, integer, float. </h3>';
- $Name = 'Md. Anwar Hossen';
- $age = 34;
- $balance =1.5;
- $br = '<br>';
- echo $Name .$br. $age .$br. $balance;
- // Using Arithmetic Operator
- echo'<h1> Using Arithmetic Operator. </h1>';
- $apple = 102;
- $orange = 34;
- $addition = $apple + $orange;
- $subtraction = $apple - $orange;
- $multiplication = $apple * $orange;
- $division = $apple/$orange;
- $modulus = $apple%$orange;
- echo'<h3> 1. Addition 102 & 34. </h3>';
- echo $addition.'</br>';
- echo'<h3> 2. Subtraction 102 & 34. </h3>';
- echo $subtraction.'</br>';
- echo'<h3> 3. Multiplacation 102 & 34. </h3>';
- echo $multiplication.'</br>';
- echo'<h3> 4. Division 102 & 34. </h3>';
- echo $division.'</br>';
- echo'<h3> 5. Modulus 102 & 34. </h3>';
- echo $modulus.'</br>';
- // Using Assignment Operator
- echo'<h1> Using Assignment Operator (=, +=, -=, *=, /=). </h1>';
- $age = 30;
- echo'<h3> 1. Adding age 5 year with previous age 30. </h3>';
- echo $age += 5; echo '</br>';
- echo'<h3> 2. Subtraction age 5 year from previous age 35. </h3>';
- echo $age -= 5; echo '</br>';
- echo'<h3> 3. Multiplication age 5 year from previous age 30. </h3>';
- echo $age *= 5; echo '</br>';
- echo'<h3> 4. Division age with 5 year to previous age 150. </h3>';
- echo $age /= 5; echo '</br>';
- // Logical Operator
- echo'<h1> Logical Operator ( ||, &&, !). </h1>';
- $username = 'anwar';
- $password = 'anwar123';
- if($username == 'anwar' && $password == 'anwar12' ){
- echo '<h2>Welcome to our website </h2>';
- }
- else{
- echo '<h2> User name or password wrong</h2>';
- }
- // Comparison Operator
- echo'<h1> Comparison Operator ( ==, !=, <, >, <=, >=, <>). </h1>';
- $Nazrul = 70;
- $Rabindra = 105;
- //one
- if($Nazrul == $Rabindra ){
- echo '<h2>There age is equel</h2>';
- }
- else{
- echo '<h2> There age is not equel</h2>';
- }
- //two
- if($Nazrul > $Rabindra ){
- echo '<h2>Nazrul is elder then Rabindra</h2>';
- }
- else{
- echo '<h2> Nazrul is younger then Rabindra</h2>';
- }
- // three
- if($Nazrul != $Rabindra ){
- echo '<h2>There age is not equel</h2>';
- }
- else{
- echo '<h2> There age is equel</h2>';
- }
- // Index Array
- echo'<h1> Index Array </h1>';
- $subject = array('English', 'Math', 'Bangla', 'Biology',);
- print_r ($subject);
- echo '</br>'. '</br>';
- echo $subject[0] .'</br>'. '</br>';
- echo $subject[1] .'</br>'. '</br>';
- echo $subject[2] .'</br>'. '</br>';
- echo $subject[3] .'</br>'. '</br>';
- // Associative Array
- echo'<h1> Associative Array </h1>';
- $student = array('Rahim'=>15, 'Karim'=>17, 'Jabbar'=>18, 'Barkat'=>21,);
- print_r ($student);
- echo '</br>'. '</br>';
- echo 'The age of Rahim is = '. $student['Rahim']. ' years' .'</br>'. '</br>';
- echo 'The age of Karim is = '. $student['Karim']. ' years' .'</br>'. '</br>';
- echo 'The age of Jabbar is = '. $student['Jabbar']. ' years' .'</br>'. '</br>';
- echo 'The age of Barkat is = '. $student['Barkat']. ' years' .'</br>'. '</br>';
- // Multidimentional Array
- echo'<h1> Multidimentional Array </h1>';
- $student = array(
- 'Rahim'=>array(
- 'roll'=>1,
- 'group'=>'Science',
- 'age'=>20,
- ),
- 'Karim'=>array(
- 'roll'=>2,
- 'group'=>'Arts',
- 'age'=>21,
- ),
- 'Jabbar'=>array(
- 'roll'=>3,
- 'group'=>'Commerce',
- 'age'=>22,
- ),
- );
- echo '<pre>';
- print_r ($student);
- echo '</br>'. '</br>';
- // ==========Rahim Details=====================
- echo '<h3>Name of Student : Rahim</h3> ';
- echo '<ol>';
- echo '<li>Roll : '. $student['Rahim']['roll']. '</li>';
- echo '<li>Group : '. $student['Rahim']['group']. '</li>';
- echo '<li>Age : '. $student['Rahim']['age']. '</li>';
- echo '</ol>';
- // ==============Karim Details==============
- echo '<h3>Name of Student : Karim</h3> ';
- echo '<ol>';
- echo '<li>Roll : '. $student['Karim']['roll']. '</li>';
- echo '<li>Group : '. $student['Karim']['group']. '</li>';
- echo '<li>Age : '. $student['Karim']['age']. '</li>';
- echo '</ol>';
- // ============Jabbar Details=================
- echo '<h3>Name of Student : Jabbar</h3> ';
- echo '<ol>';
- echo '<li>Roll : '. $student['Jabbar']['roll']. '</li>';
- echo '<li>Group : '. $student['Jabbar']['group']. '</li>';
- echo '<li>Age : '. $student['Jabbar']['age']. '</li>';
- echo '</ol>';
- // For loop increament
- echo'<h1> For loop increament </h1>';
- for($i=1; $i<=20; $i++){
- echo $i. ', ';
- }
- // For loop decreament
- echo'<h1> For loop decreament </h1>';
- for($i=20; $i>=1; $i--){
- echo $i. ', ';
- }
- // For loop even number
- echo'<h1> For loop even number </h1>';
- for($i=2; $i<=20; $i+=2){
- echo $i. ', ';
- }
- // For loop odd number
- echo'<h1> For loop odd number </h1>';
- for($i=1; $i<=20; $i+=2){
- echo $i. ', ';
- }
- // While loop
- echo'<h1> while loop </h1>';
- $i=1;
- while( $i<=20 ){
- echo $i. ', ';
- $i++;
- }
- // Foreach loop
- echo'<h1> Foreach loop </h1>';
- $father = array('Rahim'=>30, 'Karim'=>40, 'Jabbar'=>45);
- foreach($father as $sons=>$age){
- echo $sons. ' is '. $age. ' years old. <br>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement