Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is the meaning for <?php=$url?>

Status
Not open for further replies.

william6789

Technical User
Mar 14, 2003
21
0
0
CA
Hi,
There is one code syntax I could not run and I do not understand how it works yet? I copy it from one booke named "PHP and MySQL Web Development" edited by Luke Welling and Laura Thomson, Page 553. Is it a typo?

Function do_html_URL($url, $name)
{
// outpur url as a link
?>
<a href=&quot;<?=$url?>&quot;><?=$name?></a><br>
<?

}

This function could not give me a link , and I could not understand the syntax of <?=$url>.

Can someboyd give some ideas about it?

Thanks

William
 
Function do_html_URL($url, $name)
{
//this closes any open php so the quotes wont mess it up
?>

//this opens php <? then inserts a string $url then closes the php does more html and then opens the string again.
<a href=&quot;<?=$url?>&quot;><?=$name?></a><br>
//this opens up the php again
<?

}



probably would be clearer if they did it like this..

<a href=&quot; <? =$url ?> &quot;><? =$name ?></a><br>



oh i think i see what you mean... hmm no idea why the = is there.. wierd.. lemme look at my version right fast..

nope dont see it... i would say its a typo if that is whats in the book..drop the ='s and it should work fine as long as its fead the right info :D

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
I would do it like this:

Code:
function do_html_URL($url, $name) {
  // output url as a link
  ?>
  <a href=&quot;<? echo $url; ?>&quot;><? echo $name; ?></a><br>
  <?
}

This should work fine...
 
u can't put <?=, <? & ?> must be alone.. and u have to use either echo or print to output the content of a variable, like:

<a href=&quot;<? echo $url; ?>&quot;>
or
<a href=&quot;<? print $url; ?>&quot;>
but never
<a href=&quot;<? $url; ?>&quot;>

another problem u have in your function, when u close with ?>, put <a> and then re.open it <?, the <a> doesn't even belong to the function because it's out of <? ?>.

so, u should use:

<?
function do_html_URL($url, $name)
{
echo &quot;<a href=\&quot;$url\&quot;>$name</a><br>&quot;;
}
?>

Cheers,
jamesp0tter
 
Actually, jamesp0tter you can do all of that, it's just a collection of shortcuts... the possible problem is actually taken care of in the thread title... some installations of php won't recognize

<?

as an opening tag, you'll need <?php

However, I do agree with, it's a silly way to do it... I would've suggested
Code:
function doHtmlUrl($url, $name) 
{
  echo '<a href=&quot;'.$url.'&quot;>'.$name.'</a><br />';
}
but at that stage it's just whatever you're style is.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top