Learn Now

PHP Concatenation

You can combine coordinate content, and whatever is in your variable. The full stop (time frame or speck, to a few) is utilized for this. Assume you need to print out the accompanying "My variable contains the estimation of 10". In PHP, you can do it like this:


<?php

$first_number = 10;

$direct_text = 'My variable contains the estimation of ';

print($direct_text . $first_number);

?>

So now we have two factors. The new factor holds our immediate content. When we're printing the substance of the two factors, a full stop is utilized to isolate the two. Experiment with the above content, and see what happens. Presently erase the spot and after that attempt the code once more. Any blunders?

You can likewise do this kind of thing:

<?php

$first_number = 10;

print ('My variable contains the estimation of ' . $first_number);

?>

This time, the immediate content isn't inside a variable, however simply incorporated into the Print articulation. Again a full stop is utilized to isolate the immediate content from the variable name. What you've quite recently done is called connection. Attempt the new content and see what happens.

No comments