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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.