How do I include html script in a PHP variable for a link? For example I want to create a variable and store <a href=""> html script in it. How can I do this? This is what I have tried: PHP Code: $user = "<a href="www.example.com/folder/file.php">guy</a>"; echo("$user"); Code (markup): It just printed the a href=www.example.. text to the screen. And... Is there anyway I can use PHP to change the <title> tag in my html script to a PHP varible output? Thanks! ~imozeb
You need to use different quote marks, try this $string = '<a href="">Link</a>'; Code (markup): When you use single quotes you can't use variables in the string either.
This will be like this: $user = "<a href='http://www.website.com/directory/page.php'>your text</a>"; echo $user; Just look at quotes Thanks, Jimmy
Thanks guys! One more thing, is there anyway I can use PHP to change the <title> tag in my html script to a PHP varible output?
If you want to use double quotes then you need the escape the ones in the string with \ $user = "<a href=\"www.example.com/folder/file.php\">guy</a>"; echo("$user"); PHP: If you use single quotes on the echo it wont display the variable echo '$user'; PHP: will just display $user not what the variable is
@ Narrator & Imozeb Theirs no need to use parenthesis around the echo, as its optional and doesnt make any difference functionality wise. Also the quotes around echo'ing a variable are also uneeded (in this case). Furthermore instead of escaping the OP could also look into using heredoc syntax as an alternative approach: http://www.phpf1.com/tutorial/php-heredoc-syntax.html
Have a look at GenericFrame, there are much more powerful components. And you can insert them in the same way as HTML... Example: <? echo "<Button/>"; echo "<DataGrid/>"; ... ?> But it has single line of code components like Tree, DataGrid, Slider and so on... You can check the GF Explorer to see the components in action at lab.generiframe.com
use: <?php echo 'HTML CODE HERE'; ?> Code (markup): or <?php print 'HTML CODE HERE'; ?> Code (markup): or <?php include ('htmlfile.html'); ?> Code (markup):
you can write php program and can embedded the html tags. to learn more you can visit to www.w3schools.com