Page 1 of 1

Is this possible with PHP and HTML?

Posted: Sun Dec 14, 2008 12:55 am
by FacJoe

Code: Select all

 
<?php
$randomtext = "This is a random text";
?>
<div>
<h3>Header: <?php $randomtext ?> </h3>
</div>
 
I tried executing this, the variable "$randomheader"'s value does not show up.

Thanks in advance.

Re: Is this possible with PHP and HTML?

Posted: Sun Dec 14, 2008 1:03 am
by cavemaneca
FacJoe wrote:$randomtext = "This is a random text";

Code: Select all

 <div>
<h3>Header: <?php $randomtext php> </h3>
</div>
I tried executing this, the variable "$randomheader"'s value does not show up.

Thanks in advance.
First off

Code: Select all

<h3>Header: <?php $randomtext php> </h3>
Change to:
<h3>Header: <?php echo $randomtext; ?> </h3>
Second off, do you actually have some function to create this so call "random text", and if so, is it storing to the variable $randomtext before this specific set of code?

Note: please post code like this
<code=php>line 1
line 2
line 3</code>
It removes the extra lines at the beginning and end and colors it properly. (make sure you use square brackets)

Re: Is this possible with PHP and HTML?

Posted: Sun Dec 14, 2008 1:16 am
by FacJoe
First off

Code: Select all

<h3>Header: <?php $randomtext php> </h3>
Change to:
<h3>Header: <?php echo $randomtext; ?> </h3>
Second off, do you actually have some function to create this so call "random text", and if so, is it storing to the variable $randomtext before this specific set of code?

Note: please post code like this
<code=php>line 1
line 2
line 3</code>
It removes the extra lines at the beginning and end and colors it properly. (make sure you use square brackets)
Sir,

Thank you for your help. I got it working. I missed the "echo" function and the semi-colon at the end. :D