这是确切的问题.我有一个自动加载功能设置了一段代码,如下所示:
if(file_exists($class_file))
{
include($class_file);
return true;
}
Run Code Online (Sandbox Code Playgroud)
但是,当$class_file
设置为某个值时,我得到一个包含错误:
Error String: include(includes/php/utilities/calendar_event_html.utility.php)
[function.include]: failed to open stream: No such file or directory
Run Code Online (Sandbox Code Playgroud)
它适用于其他文件,当我使用调试器逐步执行此代码时,很明显PHP认为该文件存在,但似乎include
没有.有没有人知道发生了什么?
我正在浏览Zend_View源代码,我看到了这个:
include 'zend.view://' . func_get_arg(0);
Run Code Online (Sandbox Code Playgroud)
字符串" zend.view://
"表示什么以及include语句如何在php中解析?
设置包含路径真的让我很困惑.我必须遗漏一些重要的东西.
所以我在服务器的public_html文件夹中有以下脚本.
photoGallery.php
header.php
Run Code Online (Sandbox Code Playgroud)
我将我的htaccess文件设置为将具有以下结构的URL重定向到photoGallery.php
RewriteRule ^gallery/([^/]+)/([0-9]+)-([^/]+)$ photoGallery.php?imageName=$2 [L]
Run Code Online (Sandbox Code Playgroud)
所以像这样......
http://localhost/gallery/roofing/1-picture-of-roofing
Run Code Online (Sandbox Code Playgroud)
会决心......
http://localhost/photoGallery.php?imageName=1
Run Code Online (Sandbox Code Playgroud)
问题是如果URL已经被重写,那么photoGallery.php中的PHP包含将无法解析.
include 'header.php'
Run Code Online (Sandbox Code Playgroud)
所以我想设置php include路径,这样无论如何它都会解决.这是我试过的......
set_include_path(get_include_path() . PATH_SEPARATOR . "../../../");
include 'header.php';
Run Code Online (Sandbox Code Playgroud)
我也试过这样设置路径......
// get_include_path() returns .:/opt/lampp/lib/php
set_include_path(get_include_path() . PATH_SEPARATOR . "/opt/lampp/public_html");
include 'header.php';
Run Code Online (Sandbox Code Playgroud)
我从来没能成功设置包含路径.我究竟做错了什么?
我正在使用Visual Studio 2008 Express版,并且不断收到以下错误:
"Cascadedisplay.h(4) : fatal error C1014: too many include files : depth = 1024
.
显然我对包含文件做了一些非常错误的事情,但我看不出是什么.
基本上,我有一个接口类,StackDisplay
我想从中导出CascadeDisplay
另一个文件:
#if !defined __BASE_STACK_DISPLAY_H__
#define __BASE_STACK_DISPAY_H__
#include <boost\shared_ptr.hpp>
#include "CascadeDisplay.h"
namespace Sol
{
class StackDisplay
{
public:
virtual ~StackDisplay();
static boost::shared_ptr<StackDisplay>
make_cascade_display(boost::shared_ptr<int> csptr)
{
return boost::shared_ptr<StackDisplay>(new CascadeDisplay(csptr));
}
};
}
#endif
Run Code Online (Sandbox Code Playgroud)
然后在CascadeDisplay.h中:
#if !defined __CASCADE_DISPLAY_H__
#define __CASCADE_DISPAY_H__
#include "StackDisplay.h"
#include <boost\shared_ptr.hpp>
namespace Sol
{
class CascadeDisplay: public StackDisplay
{
public:
CascadeDisplay(boost::shared_ptr<int> csptr){};
};
}
#endif
Run Code Online (Sandbox Code Playgroud)
那有什么用呢?
我是C++的新手,需要第一次使用库.我希望有人能够告诉我如何正确地[链接到/包含]图书馆.
我想使用的库是ID3 v3.8.8,可以在这里找到:http://id3lib.sourceforge.net/
我已经下载了Windows二进制文件,现在只需要一种链接到库的方法.
下载的文件:Debug/id3lib.dll,Debug/id3lib.lib,Debug/id3lib.exp,Release/id3lib.dll,Release/id3lib.lib,Release/id3lib.exp
我正在使用Visual Studio 2010.
任何帮助是极大的赞赏.提前致谢.
自从我完成C++以来已经很长时间了,我遇到了相互引用类的麻烦.
现在我有类似的东西:
啊
class a
{
public:
a();
bool skeletonfunc(b temp);
};
Run Code Online (Sandbox Code Playgroud)
BH
class b
{
public:
b();
bool skeletonfunc(a temp);
};
Run Code Online (Sandbox Code Playgroud)
由于每个人都需要引用另一个,我发现我不能在顶部做彼此的#include,或者我最后在包含的奇怪的循环中.
那么,如何让这个a
可以使用b
并且没有发生周期性的#include问题反之亦然?
谢谢!
我如何tar多个目录,并附加一些模式,如'.txt',并排除一些目录,并将一些模式,如'.exe'全部排除在一个tar文件中.主要的一点是目录的数量是未知的(动态的),所以我需要循环通过我猜?
我必须使用经典的ASP来建立一个网站.我希望能够使用包含文件的页眉和页脚.
如何将变量传递给包含文件,以便我可以影响标题等等.以下是我想要做的一些示例:
的index.asp
<%
dim title
title="TITLE"
'Server.Execute("header.inc") <--- Note I tried this but it didnt work also
%>
<!--#include file="header.inc" -->
Run Code Online (Sandbox Code Playgroud)
header.inc
<html>
<head>
<title><% Response.write title %></title>
Run Code Online (Sandbox Code Playgroud) 当我添加#include <cstdio>
到C程序时,我在cstdio中遇到了大量错误.
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio(17) : error C2143: syntax error : missing '{' before ':'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio(17) : error C2059: syntax error : ':'
Run Code Online (Sandbox Code Playgroud)
谢谢
编辑 - 我想使用snprintf,这就是我试图包含这个的原因.
我正在制作一个小的C++框架,其中包含许多.h和.cpp.
我创建了一个包含所有.h文件的常规包含,例如:
framework.h
#include "A.h"
#include "B.h"
#include "C.h"
Run Code Online (Sandbox Code Playgroud)
每个.h标题都受到包含保护的保护
#ifndef A_HEADER
#define A_HEADER
...
#endif
Run Code Online (Sandbox Code Playgroud)
问题是,我希望能够在所有sub .h中包含"framework.h",但是它会导致很多编译器错误:
#ifndef A_HEADER
#define A_HEADER
#include "framework.h"
...
#endif
Run Code Online (Sandbox Code Playgroud)
如果相反,我使用每个子标头的真实头文件,而framework.h用于什么使用我的框架它工作正常..
我只想在所有sub .h中包含主标题,所以我不需要每次都包含所有依赖项.
谢谢 :)