"Con","cat","en","ation" |
Code for Concatenate in php (Screenshot1):-
Concatenation in php Screenshot1 |
<?php $day = 'Thursday'; $date = 31; $year = 2011; echo 'The date is '.$day.' '.$date.' ' .$year; ?>
Output (Screenshot2) :-
Screenshot2 |
In this code of concatenate in php I am creating three variables i.e. $day, $date, $year.Now to echo one or more variables we have to join variables with dot which is called as concatenate. In single quotation (‘) inside echo statement we are echoing variables and text.Blank single quotation (‘) is used to leave space between variables.With Single quotation (‘) concatenate feature is most useful and with Double quotation (“) too its easy which I will so you in later tutorials.
Code For Concatenate in php (Screenshot3):-
Screenshot3 |
<?php
$day = 'Wednesday';
$date = 30;
$year = 2011;
echo 'The date is '.$day.' '.$date.' ' .$year;
?>
Output (Screenshot4) :-
In this examples i just updated variables and its automatically update output.So this is harder but fastest way to echo out variables by concatenate in string data.
Code for concatenate in php (Screenshot5):-
Screenshot4
In this examples i just updated variables and its automatically update output.So this is harder but fastest way to echo out variables by concatenate in string data.
Code for concatenate in php (Screenshot5):-
Screenshot5 |
<?php $day = 'Wednesday'; $date = 30; $year = 2012; echo 'The date is <strong>'.$day.' '.$date.' ' .$year.'</strong>; ?>
Output (Screenshot6):-
Screenshot6 |
In this example i am including html tags strong tag with concatenate strings, variables and also html tags.In this code it will bold variables.
Code for Concatenate in php with Double quotation marks(Screenshot7):-
Screenshot7 |
<?php
$day = 'Wednesday';
$date = 30;
$year = 2011;
echo "The date is $day $date $year";
?>
Output (Screenshot4) :-
Screenshot4 |
Code for Concatenate in php (Screenshot8):-
Screenshot8 |
<?php $day = 'Wednesday'; $date = 30; $year = 2011; echo 'The date is $day $date $year'; ?>
output (Screenshot9):-
Screenshot9 |
In this code if we use single quotation mark without concatenate with dot (.) it will echo variable name and does not reference to variable values.
No comments:
Post a Comment
Thanks For Comment Will get you Soon..