Solved

How to make output display as compiled PHP

Posted on 2014-10-18
5
157 Views
Last Modified: 2014-10-18
I have queried my database and output the field named "code_output". It is my intention for this field to hold html and php. When it displays, the html compiles and displays correctly, but the php does not compile. It literally shows the php code.

In other words, it will output, <table border="1"><tr><td>test</td></tr></table> AS AN ACTUAL TABLE

But when I use, <?php echo "test"; ?>, It doesn't compile, It LITERALLY DISPLAYS <?php echo "test"; ?>

How can I display the query and output as compiled php?

Tis is the simple line of code:
echo $code_output;
0
Comment
Question by:edavo
  • 3
  • 2
5 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40389642
I don't believe that you can.  Since the data that your query returns is Not part of the PHP file, it is simply handled as text.  It is not passed to the PHP interpreter to be 'executed'.
0
 

Author Comment

by:edavo
ID: 40389643
So there's no "simple" way to have an online php editor/tester - like a JS fiddle?
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40389656
Right, no "simple" way.  This search https://www.google.com/search?q=php+online+editor will list a number of 'online' PHP editors but "simple" is not what I would call them.  This one http://www.compileonline.com/execute_php_online.php looks interesting.  Since PHP is capable of accessing the files on the server, an application like that has to create a "sandbox" to restrict the operation of PHP to a safe environment that can't damage the server.
0
 

Author Comment

by:edavo
ID: 40389658
Gotcha - thank you very much…
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40389660
You're welcome, glad to help.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question