使用echo但需要一些东西来执行PHP代码 [英] using echo but need something to execute php code

查看:56
本文介绍了使用echo但需要一些东西来执行PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码可以加载一些php / html文件并执行一些操作来获取它们并最终返回一个带有一些php代码的html文件。然后我用
通过echo将该文件传递给用户。当然,文件不会被用户看到



是否有任何命令基本上执行代码然后回显''它?


会带一些像


''< body> blah<?php echo''Hello''; ?>< / body>''实际上解释了php

代码?


例如,做


echo''< body> blah<?php echo''Hello''; ?>< / body>'';


我没有好担心PHP代码无法解释。


Saving它到一个文件,然后将用户重定向到该文件所以它将执行似乎是一种迂回的方式并导致更多问题。

本质上我试图包含php / html文件在另一个,但我需要

首先对它们进行一些解析。我宁愿不做类似的事情

file_get_contents($ Page)

parse($ Page)

save($ Page)

包括$ Page

因为看起来必须将页面写入磁盘只是为了包含它。


At

http://us2.php.net/include/

另一种方式包括变量中的PHP文件是通过使用带有include()的输出控制函数来捕获

输出。例如:


当我使用

file_get_contents来执行php代码时,我似乎可以使用它来替换?


谢谢,

Jon

I have some code that loads up some php/html files and does a few things to
them and ultimately returns an html file with some php code in it. I then
pass that file onto the user by using echo. Of course then the file doesn''t
get seen by the user.

Is there any command that essentially executes the code and then echo''s it?

something that will take a string like

''<body>blah<?php echo ''Hello''; ?></body>'' and actually interpret the php
code?

e.g., doing

echo ''<body>blah<?php echo ''Hello''; ?></body>'';

does me no good caues the php code isn''t interpreted.

Saving it to a file and then redirecting the user to that file so it will be
executed seems like a roundabout way and causes more problems.
essentially I am trying to include php/html files in one another but I need
to do some parsing on them first. I''d rather not do something like
file_get_contents($Page)
parse($Page)
save($Page)
include "$Page"
as it seems uncessary to have to write the page to disk just to include it.

At

http://us2.php.net/include/
"Another way to "include" a PHP file into a variable is to capture the
output by using the Output Control Functions with include(). For example:"

Seems like I might be able to use that to replace when I use
file_get_contents to get the php code to execute?

Thanks,
Jon

推荐答案

Page)

解析(
Page)
parse(


页面)

save(
Page)
save(


页面)

包括
Page)
include "


这篇关于使用echo但需要一些东西来执行PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆