print <<<(html code)- the only solution to display

A

Anonymous

Guest
Hi coderz,

i need to print some php variables in html (retrieved as POST vars after submitted by a form). i have read in many sites that its not possible...
is this true?

i understand one technique that works.. is this the only solution to displayin php variables in html code?

the technique is printing the html code using the print <<< function ->

Code:
//initial html tags
<?PHP
print <<<TOEND

... some html code ... if any that needs to display php variables...
TOEND;
?>

//remaining html tags

Is this technique advisable? with regard to performance, especially if the content to be printed (using print<<< is very large)

If there are any other ways to embed php variables in html please tell me of them..

thanks.
Fazbob
 
fazbob said:
i need to print some php variables in html (retrieved as POST vars after submitted by a form). i have read in many sites that its not possible...
is this true?

No, that's not even remotely true; if it were, PHP would be a singularly useless language.

PHP has many ways to print variables and it won't surprise you, I'm sure, that this is thoroughly covered in the documentation. The best place to start is the documentation on Strings (which in learning the language I'm sure you've read before, it being part of one of the most fundamental chapters).

But I'll give you some examples anyway:

Code:
<?php

$value = 'ABC';

echo 'The value of the variable is ' . $value;
// output: The value of the variable is ABC

echo "The value of the variable is $value";
// output: The value of the variable is ABC

echo <<<END
The value of the variable is $value
END;
// output: The value of the variable is ABC
?>

The value of the variable is <?php echo $value; ?>
 
Back
Top