Is this possible with PHP and HTML?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
FacJoe
Forum Newbie
Posts: 8
Joined: Sun Dec 07, 2008 7:49 pm

Is this possible with PHP and HTML?

Post 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.
cavemaneca
Forum Commoner
Posts: 59
Joined: Sat Dec 13, 2008 2:16 am

Re: Is this possible with PHP and HTML?

Post 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)
FacJoe
Forum Newbie
Posts: 8
Joined: Sun Dec 07, 2008 7:49 pm

Re: Is this possible with PHP and HTML?

Post 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
Post Reply