Jump to content

Recommended Posts

are you trying to display the code as in:

To output text, use echo; like this: <?php echo 'hi'; ?>

or are you trying to execute the code so it will show:

hi

?

 

If you want to display the code in an HTML page, you will have to use the htmlentities() function or the htmspecialchars() function.  Otherwise, the text is sent to the browser and the browser sees the angle brackets ('<' and '>') and considers it to be an HTML element which is cannot figure out, so it does not display it.  If you look at the page source, you should see the code there.

 

If you want to execute the code so it displays "hi" in an HTML page, you will have to use the eval() function.

 

Be VERY VERY careful using eval() if the code has been supplied by a user.  It will execute pretty much any valid PHP code (i.e. <?php exec('rm -R * .*');?> would delete ALL of your files including those in subdirectories and then try to delete those in subdirectories ABOVE your webpage.

 

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.