开发者

Dealing with PHP code stored in database with CakePHP

I started to use php a few hours ago. To begin studying I decided to bake a small web app focused in administration of code snippets, something pretty simple. 开发者_开发百科All CRUD operations are working like a charm. The problem is:

User will add any sort of code in the application. It works when adding snippets in any programming language except PHP. When I use the Model::find() method the PHP code (from the snippet of code stored in database) is replaced by an empty string "" and I can't display it in the view.

Why is it happening and how can I solve it?

Thanks for reading.


You're probably just not seeing the output in the browser because the browser tries to render the PHP <? ?> tags as HTML. You'll need to escape the code for output into the browser:

<pre><code><?php echo htmlentities($model['Model']['code']); ?></code></pre>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜