http://php.flashwebhost.com/sherly/add.php
Code:<?php $M = 20; $N = 50; echo $M + $N;
http://php.flashwebhost.com/sherly/add.php
Code:<?php $M = 20; $N = 50; echo $M + $N;
Become PHP Expert in 30 days
FreeMarriage.com - Free Online Matrimonial
FlashWebHost.com - Professional Web Hosting, Designing.
I got an error while adding break in http://php.flashwebhost.com/annie/company.php
Code:Parse error: syntax error, unexpected '>' in /home/fwhphp/public_html/annie/company.php on line 3Code:<?php $companyname = 'Relience'; echo $companyname <br> ; $companyname = 'Whirpool'; echo $companyname ;
I got an error http://php.flashwebhost.com/sherly/name.php
Code:Parse error: syntax error, unexpected '' ;' (T_ENCAPSED_AND_WHITESPACE), expecting ',' or ';' in /home/fwhphp/public_html/sherly/name.php on line 7Code:<?php $my_string = 'Hi Meera. My anme is Neena'; $my_number = 8; $my_letter = N; echo $my_string; echo $my_number; echo $my_letter' ;
Last edited by sherlyk; 05-09-2014 at 07:08 AM.
Good, more friendly code with some string.
Code:<?php $my_string = 'Hi Meera. My anme is Neena'; $my_number = 8; $my_letter = N; echo '<h1>About Me</h1>'; echo $my_string; echo '<br>'; echo 'My number is ' . $my_number; echo '<br>'; echo 'My Name start with ' . $my_letter' ; echo '<br>';
Become PHP Expert in 30 days
FreeMarriage.com - Free Online Matrimonial
FlashWebHost.com - Professional Web Hosting, Designing.
Problem is on line number 3.
To fix, replace that line withCode:echo $companyname <br> ;
$companyname is a variable. We use DOT to join it with string <br>. String should start with a quote, end with a quote.Code:echo $companyname . '<br>' ;
As for variable name, proper naming convention is $companyName, because it is two words, and easy to read.
Fixed code
Code:<?php $companyName = 'Relience'; echo $companyname . '<br>'; // here we store another text to same variable $companyName $companyName = 'Whirpool'; echo $companyname ;
Become PHP Expert in 30 days
FreeMarriage.com - Free Online Matrimonial
FlashWebHost.com - Professional Web Hosting, Designing.
http://php.flashwebhost.com/annie/day_2_variables_3.php
Code:<?php $name = 'George'; $Rank = 1; $Mark = 800; $School = 'Raja Giri Public School'; echo $name . ' from ' . $School . ' got Rank ' . $Rank . ' He have ' . $Mark . 'Marks';
I didn't get the correct answer. http://php.flashwebhost.com/sherly/variable.php
Code:<?php $variable12 = $variable7 + $variable5; echo $variable7; echo " + "; echo $variable5; echo " = "; echo $variable12;
http://php.flashwebhost.com/sherly/age.php
Code:<?php $name = 'Joseph'; $yearBorn = 1975; $currentYear = 2014; $age = $currentYear - $yearBorn; print ("$name is $age years old. ")
Semicolon at end of print statement missing.
print function same as echo, but use echo, forget print. echo is more popular, also there are more ways to print, some complicated, but is not required for most programming project.
Proper usageCode:print ("$name is $age years old. ")
OrCode:echo $name . ' is ' . $age . ' years old. ';
Advantage of using single quote is PHP know it is just string, so it will be faster. If using double quote, PHP compilter need to look for variable inside the string and convert it to its value, that need more processing time (not much, still do that way as a convention whenever possible).Code:echo "$name is $age years old. ";
Become PHP Expert in 30 days
FreeMarriage.com - Free Online Matrimonial
FlashWebHost.com - Professional Web Hosting, Designing.
Bookmarks