Become PHP Expert in 30 days
FreeMarriage.com - Free Online Matrimonial
FlashWebHost.com - Professional Web Hosting, Designing.
http://php.flashwebhost.com/sherly/abc.php
Code:Parse error: syntax error, unexpected '{' in /home/fwhphp/public_html/sherly/abc.php on line 5Code:<?php if ($a > $b) { echo 'a is bigger than b'; } esle if ($a == $b) { echo 'a is equal to b'; } else ($a < $b) { echo 'a is smaller than b'; }
Last edited by sherlyk; 05-13-2014 at 07:04 AM.
First of all, where did you set $a and $b ? With out such a variable how it works ?
The error is because
Spelling mistake, use else ifesleif
Fixed code
Code:<?php $a = 1; $b = 100; if ($a > $b) { echo 'a is bigger than b'; } else if ($a == $b) { echo 'a is equal to b'; } else ($a < $b) { echo 'a is smaller than b'; } echo '<p>Value of $a = ' . $a . ' and value of $b = ' . $b . '</p>';
Become PHP Expert in 30 days
FreeMarriage.com - Free Online Matrimonial
FlashWebHost.com - Professional Web Hosting, Designing.
http://php.flashwebhost.com/sherly/ressult.php
Code:<?php $result = 80; if ($result >= 85) { echo "Passed: Grade A <br />"; } elseif ($result >= 70) { echo "Passed: Grade B <br />"; } elseif ($result >= 65) { echo "Passed: Grade C <br />"; } else { echo "Failed <br />"; }
http://php.flashwebhost.com/annie/cow_can_fly.php
Code:<?php $cowsCanFly = 'no'; //try changing value to 'no' if ($cowsCanFly == 'yes' ) { echo 'There is no time like the present '; } if ($cowsCanFly == 'no' ) { echo 'When in Rome, do as the Romans'; }
Become PHP Expert in 30 days
FreeMarriage.com - Free Online Matrimonial
FlashWebHost.com - Professional Web Hosting, Designing.
http://php.flashwebhost.com/austin/day4.php
Stefin ... run!!!!Code:<?php$animal = 'tiger'; $color = 'green'; if($animal == 'frog'){ if($color=='green'){ echo 'You are green frog'; } else echo 'You are an invisible frog'; } else if($animal=='dragon'){ if($color == 'green') echo 'You are a green dragon and stefin got your eggs :D'; else if($color=='red') echo ' You are a red dragon and stefin is coming to steal ur eggs too :D'; } else{ echo 'i know you are a tiger and you are green.'; }
Become PHP Expert in 30 days
FreeMarriage.com - Free Online Matrimonial
FlashWebHost.com - Professional Web Hosting, Designing.
http://php.flashwebhost.com/vineesh/...n_making_1.php
------------------------Code:<?php $ticket = 'no'; if ($ticket == 'yes') { echo 'We will get ticket' ; } if ($ticket == 'no') { echo 'We will not get ticket' ; }
http://php.flashwebhost.com/vineesh/...n_making_2.php
Code:<?php $mark = 99; if ($mark == 99) { echo 'You have got 99 marks, you win!'; } if ($mark == 19) { echo 'Sorry, You are failed'; }
http://php.flashwebhost.com/vineesh/...n_making_3.php
and my code is as follows:
Code:<?php $passMark = 35; $student1Name = 'Manu'; $student1Mark = 34; $student2Name = 'Saritha'; $student2Mark = 60; $student3Name = 'Sudhi'; $student3Mark = 93; $class1 = 'First Class'; $class2 = 'Distinction'; echo 'Passmark = ' . $passMark . '<br> <br>' ; echo 'Student names with marks <br> <br>'; echo $student1Name . ' = ' . $student1Mark . ' marks. <br>' ; echo $student2Name . ' = ' . $student2Mark . ' marks. <br>' ; echo $student3Name . ' = ' . $student3Mark . ' marks. <br> <br>' ; if ($student1Mark < $passMark) { echo $student1Name . ', you have got only ' . $student1Mark . ' marks and you are failed. <br>' ; } if ($student2Mark > $passMark) { echo $student2Name . ', you have got ' . $student2Mark. ' marks and you passed with ' . $class1 . '<br>' ; } if ($student3Mark > $passMark) { echo 'Congratulations ! ' . $student3Name . '!. You have got ' . $student3Mark . ' marks and you passed with ' . $class2 ; }
Bookmarks