Jump to content

[SOLVED] is this the right way to put a function in a echo


nathanmaxsonadil

Recommended Posts

you are getting error b/c of the single quotes that are around the name of the href= and around the _SERVER element.

 

Single quotes are not like parentheses; they don't nest inside of each other (generally....you might be able to  create a bizzarre situation where they would, but let's not get into that now :)  )

 

When I'm writing code, if I have a variable that refers to an array element, then I concatenate it using .

so:

 

echo "<li><a href=' . $_SERVER['PHP_SELF'] . " ?example= " .myfunction($myvar['test']) . " &somethingelse=goeshere' ";

 

I put in some extra spaces to make it more obvious.

 

another thing I will do is build a $page_content that all the html code gets added to as it builds, then echo $page_content when it's all finished.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.