简体   繁体   English

分别在网页上执行一段PHP代码

[英]Separately execute a section of php code on a web page

This is a best practice type question. 这是一个最佳实践类型的问题。 I'm dealing with two different frameworks. 我正在处理两个不同的框架。 When I execute a piece of code from one framework on the page of another framework, I'm getting a code conflict. 当我从另一个框架的页面上的一个框架执行一段代码时,我遇到了代码冲突。 What I'm wondering is how to execute a piece of code on a separate web page and bring in the results AFTER the php on that page has executed and produced its HTML. 我想知道的是如何在该网页上的php执行并产生其HTML之后,在一个单独的网页上执行一段代码并带来结果。

One Possible Solution 一种可能的解决方案

Use Curl - I could house the additional code on a curl page and bring it in that way, but that seems to have a lot of overhead associated with it. 使用Curl-我可以将其他代码放在curl页面上,并以这种方式进行添加,但这似乎有很多开销。

Is there a lower overhead way of doing this than using curl? 有没有比使用curl更低的开销方式?

More info 更多信息

Specifically in this case I'm trying to use a magento php script in my page, and the autoloader is trying to load in other scripts in the directory that should not be auto loaded. 特别是在这种情况下,我试图在页面中使用magento php脚本,而自动加载器则试图加载不应自动加载的目录中的其他脚本。

Resolve the 'conflict' by wrapping the library code in an class where you define the interface. 通过将库代码包装在定义接口的类中来解决“冲突”。 Then call that class directly. 然后直接调用该类。

Adding a server side request to another resource will extend the time each request takes (remember the second request has to fire up a database connection, load the framework, carry out a db query etc). 将服务器端请求添加到另一个资源将延长每个请求所花费的时间(请记住第二个请求必须启动数据库连接,加载框架,执行db查询等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM