网上有很多关于包含ZEND的内容,但我仍然不知道如何简单地使用它(没有骨架)(在这种情况下我只想使用Zend\Dom\Query )
我想要: 1)只需在单个应用程序中包含完整的ZEND 2.3库 要么 2)包括一个ZEND 2.3模块
我正在使用NGINX,但实际上我只想通过PHP包含它。 任何提示,提示和/或链接?
我所做的是:
include('./library/Zend/Dom/Query.php'); $c = curl_init($u); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $html = curl_exec($c); $dom = new Zend\Dom\Query($html); $results = $dom->execute('.foo .bar a'); ...错误是: Fatal error: Class 'Zend_Dom_Query' not found in /SOMEDIR/myfile.php on line 12
There is a lot on the web about including ZEND, but I still don't get how to simply use it (without a skeleton) (In this case I only want to use Zend\Dom\Query)
I would like to: 1) Simply include the complete ZEND 2.3 library in a single application or 2) Include a single ZEND 2.3 module
I'm using NGINX, but actually I just want to include it via PHP. Any hints, tips and or links?
What I did was:
include('./library/Zend/Dom/Query.php'); $c = curl_init($u); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $html = curl_exec($c); $dom = new Zend\Dom\Query($html); $results = $dom->execute('.foo .bar a'); ...Error is: Fatal error: Class 'Zend_Dom_Query' not found in /SOMEDIR/myfile.php on line 12
最满意答案
通过PHP包含它的一种简单方法是:
1.确保Zend目录位于php include_path 。 假设Zend目录在library文件夹中,你的index.php文件中会有这样的东西:
$path= array(); $path[] = '.'; $path[] = './../library'; $path[] = get_include_path(); $path= implode(PATH_SEPARATOR,$path); set_include_path($path);2.现在首先包含Zend/Loader/StandardAutoloader.php ,然后使用它来加载其他类。 你可以这样做 :
require_once 'Zend/Loader/StandardAutoloader.php'; $autoloader = new Zend\Loader\StandardAutoloader(array( 'fallback_autoloader' => true, )); $autoloader->register();使用$autoloader->register() ,每次要调用类时都不需要包含文件。 你只需要实现你的课程:
$dom = new Zend\Dom\Query($html);A simple way to include it via PHP is :
1. Make sure that the Zend directory is on your php include_path. Assuming Zend directory is in the library folder you'll have something like this in your index.php file:
$path= array(); $path[] = '.'; $path[] = './../library'; $path[] = get_include_path(); $path= implode(PATH_SEPARATOR,$path); set_include_path($path);2. Now just include Zend/Loader/StandardAutoloader.php first and then use it to load other classes. You can do this :
require_once 'Zend/Loader/StandardAutoloader.php'; $autoloader = new Zend\Loader\StandardAutoloader(array( 'fallback_autoloader' => true, )); $autoloader->register();With the $autoloader->register(), you don't need to include files each time you want to call classes. You have just to instanciate your classes :
$dom = new Zend\Dom\Query($html);更多推荐
发布评论