-
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 ;
}
-
DAY 4 PHP PROGRAMMING
http://php.flashwebhost.com/tom/trai..._Ernakulam.php
Code:
<?php
$trainGoesToErnakulam = 'no';
if ($trainGoesToErnakulam == 'yes')
{
echo 'I Will Enter The Train.';
}
if ($trainGoesToErnakulam == 'no')
{
echo 'I Will Not Enter The Train.';
}
-
DAY 4 PHP PROGRAMMING
http://php.flashwebhost.com/tom/if_greater.php
Code:
<?php
$passMark = '35';
$studentName = 'Tom';
$studentMark = '60';
if ($studentMark>$passMark)
{
echo 'Congratulations '. $studentName . ' ! You passed exam with ' . $studentMark . ' marks.';
}
-
DAY 4 PHP PROGRAMMING
http://php.flashwebhost.com/tom/if_else_greater.php
Code:
<?php
$passMark = '35';
$studentName = 'Tom';
$studentMark = '30';
if ($studentMark > $passMark) {
echo 'Congratulations '. $studentName . ' ! You passed exam with ' . $studentMark . ' marks.';
} else {
echo ' Sorry! You failed. Good luck next time.' ;
}
-
DAY 4 PHP PROGRAMMING
http://php.flashwebhost.com/tom/if_else_greater_bug.php
Code:
<?php
$passMark = '35';
$studentName = 'Tom';
$studentMark = '35';
if ($studentMark >= $passMark) {
echo 'Congratulations ' . $studentName . ' ! You passed exam with ' . $studentMark . ' marks' ;
}
else
{
echo 'Sorry! You failed. Good luck next time.' ;
}
-
http://php.flashwebhost.com/vineesh/...n_making_5.php
Code:
<?php
$rain = 'eeeee';
if ($rain == 'yes') {
echo 'It will rain today.';
}
else if ($rain == 'no') {
echo 'It will not rain today.';
}
else {
echo 'huh...what is this ?';
}
-
DAY 4 PHP PROGRAMMING
http://php.flashwebhost.com/tom/cow_version_2.php
Code:
<?php
$trainGoesToErnakulam = 'when';
if ($trainGoesToErnakulam == 'yes') {
echo 'I Will Enter The Train.'; }
else if ($trainGoesToErnakulam == 'no')
{
echo 'I Will Not Enter The Train.';
}
else
{
echo 'I will go at 11 AM.';
}
-
{ and } not properly aligned in tom and vineesh's codes. It should be like
Code:
if (CONDITION) {
// do some thing if true
} else {
// do another thing
}
It is OK, just coding style, it is better to follow proper coding style from the beginning.
Variable names are perfect.
Updated code for
http://php.flashwebhost.com/vineesh/...n_making_5.php
Code:
<?php
$rain = 'eeeee';
if ($rain == 'yes') {
echo 'It will rain today.';
} else if ($rain == 'no') {
echo 'It will not rain today.';
} else {
echo 'huh...what is this ?';
}
-
PHP PROGRAMING DAY - 4 MY 1'ST CODE
http://php.flashwebhost.com/ramesh/d..._is_better.php
Code:
<?php
$sachinisbetter = 'yes';
if ($sachinisbetter =='yes'){
echo 'Sachin is a great cricketer. He is better than Lara';
}
echo '<br>';
$laraisbetter = 'no';
if ($laraisbetter == 'yes'){
echo 'Lara is better than sachin';
}