标签: include-path

如何构建PHP的内容包括在非安全(http://)和安全(https://)区域以及跨多个目录使用?

我有一个包含链接和图像的页脚文件.该文件在我的主页和多个目录中使用.在用户登录后,它也会在我网站的安全部分(https://)上使用.

组织链接的最佳方式是什么,以便(1)它们可以在我网站的非安全(http://)和安全(https://)区域中使用,而(2)也能够在我的网站的不同目录中使用include?

看来为了满足我的第一个要求(1),我必须使用相对链接; 但是,为了满足我的第二个要求(2),我需要使用绝对链接.

你能提供的任何帮助都会很棒!

<div id="footer">
    <a href="http://www.sample-link.com" target="_blank"> 
        <img id="sample-image" src="http://<? print $_SERVER['SERVER_NAME'] ?>/media/sample-image.png" /> 
    </a>
</div>
Run Code Online (Sandbox Code Playgroud)

php https include hyperlink include-path

3
推荐指数
1
解决办法
114
查看次数

Drupal模块代码重用

我使用node_clone模块效果很好但我的项目中需要使用自定义模块中的node_clone函数.所以我输入以下代码:

module_load_include('inc', 'node_clone', 'clone.pages');

function mymodule_init(){
    clone_node_save(118);
}
Run Code Online (Sandbox Code Playgroud)

该代码返回Fatal error: Call to undefined function clone_node_save().

我的模块按来源分类为标记为minecontrib的目录.Node_save在contrib中,而myModule在我的中.

所以,我按照以下方式修改了代码:

module_load_include('inc', '../../contrib/node_clone', 'clone.pages');
Run Code Online (Sandbox Code Playgroud)

但我得到了同样的错误.

有人能突出我做错了吗?

code-reuse drupal include-path drupal-7 drupal-modules

3
推荐指数
1
解决办法
272
查看次数

JavaScript相对AJAX调用路径

我有一个包含PHP和JavaScript文件的脚本.所有这些文件都在根文件夹中/myfolder.

让我说我必须在我的网站上包含的脚本是/myfolder/script.js,问题是script.js我有ajax调用../myfolder/ajax.php,因为路径将相对于页面包含脚本将无法工作,如果我有这样的东西页面/a/b/page.php:

<script src="../../myfolder/script.js><script>因为这将调用AJAX调用中所述的ajax方法../myfolder/ajax.php,在本例中是/a/myfolder/ajax.php.

如何重写AJAX调用URL,以便它始终指向正确的文件,无论script.js它包含在哪里?

ROOT
|---myfolder
    |--script.js
    |--ajax.php
|--page1.php
|--subfolder
   |--page2.php
   |--subfolder
      |--page3.php
Run Code Online (Sandbox Code Playgroud)

javascript relative-path include-path

3
推荐指数
1
解决办法
7302
查看次数

PHP API客户端中的required_once问题

我一直在尝试导入/包含我的PHP脚本文件中的文件,并以某种方式它无法正常工作.我知道这个require_once问题被多次询问[ 1. require_once with subfolders,2.require_once()无法找到包含路径,3.使用require_once for up directory not working ]但是它们似乎都不适用于我.

Blow图片将解释我想要做的事情: 在此输入图像描述

我尝试了什么和错误:

尝试1

require_once(__DIR__.'GoogleClientApi/src/Google/Service/Analytics.php');
echo 'Hey1';  //Does not echo this, means something went wrong above.
require_once(__DIR__.'GoogleClientApi/src/Google/Client.php');
echo 'Hey2';
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我得到的错误:

在此输入图像描述

尝试2(修复了尝试1的问题但提出了另一个问题.)

所以我决定使用绝对路径:

include '/Applications/MAMP/htdocs/GoogleClientApi/src/Google/Client.php';
echo 'Hey1';
include '/Applications/MAMP/htdocs/GoogleClientApi/src/Google/Service/Analytics.php';
echo 'Hey2';
Run Code Online (Sandbox Code Playgroud)

给我Client.php文件中的错误:

`Warning: require_once(/Google/Auth/AssertionCredentials.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/GoogleClientApi/src/Google/Client.php on line 18`

`Fatal error: require_once(): Failed opening required '/Google/Auth/AssertionCredentials.php' (include_path='.:/Applications/MAMP/bin/php/php5.5.10/lib/php') in /Applications/MAMP/htdocs/GoogleClientApi/src/Google/Client.php on line 18`

Investigating upon I found …
Run Code Online (Sandbox Code Playgroud)

php google-analytics require-once include-path google-api-php-client

3
推荐指数
1
解决办法
7115
查看次数

Varnish include 在同一目录中找不到文件

在我的清漆 default.vcl 中,我有以下代码:

include "vars.vcl";
Run Code Online (Sandbox Code Playgroud)

当我尝试启动清漆时,我收到以下错误消息:

Message from VCC-compiler:
Cannot read file 'vars.vcl': No such file or directory
('input' Line 6 Pos 9)
include "vars.vcl";
--------##########-

Running VCC-compiler failed, exited with 2

VCL compilation failed
Run Code Online (Sandbox Code Playgroud)

文件“vars.vcl”位于目录 /etc/varnish/ 中,其中还存储了 default.vcl。它是实际 vars.vcl 的符号链接。

我不知道为什么包含不起作用,可能是清漆不能使用符号链接吗?为什么找不到文件?

include varnish include-path varnish-vcl

3
推荐指数
1
解决办法
2145
查看次数

php在文件路径之前包含".."

我最近正在观看一个php视频教程,作者正在展示如何包含一个文件.他正在使用XAMPP进行演示并拥有许多文件.

当他展示如何包含文件时,他提到了在文件路径(/xampp/content/example.html)前放置两个点(..)的原因,因为有些内容与文件的位置有关,假设我已经了解这个原则.但我没有.

任何人都可以解释在文件路径前面有一个点或两个点的情况吗?

是什么区别include("/xampp/content/example.html");,include("./xampp/content/example.html");include("../xampp/content/example.html");

php include-path

3
推荐指数
1
解决办法
1236
查看次数

包含带有预处理器定义的文件

我想包含一个文件并使用路径的预处理器定义。

// in projects preprocessor definitions:    
HEADER="../somePath/theHeader.h"

// in a file
#include HEADER
Run Code Online (Sandbox Code Playgroud)

这在 Windows 上有效,但 XCode 抱怨这一点并且找不到该文件。替换HEADER为路径有效,因此该文件确实存在。那么,我错过了什么?

c++ macros include-path c-preprocessor

3
推荐指数
1
解决办法
2251
查看次数

C++在#include指令中使用..(点点)是否合法?

那里.正如标题所说.

使用#include"test.h"是合法的.
使用#include"test/test.h"也是合法的.
但使用合法#include"../test.h"吗?

例如,#pragma once几乎每个编译器都是合法的.
但这不是C++的标准.

我找不到任何说"保证"是父目录含义的文件.
谁能帮我?

c++ include include-path

3
推荐指数
1
解决办法
614
查看次数

如何让 C/C++ 编译器在用户指定的路径中查找头文件

我正在使用其他人编写的库,它有点基于 C 用于 C++ 用法-我认为-。头文件或源文件中使用的所有包含内容都采用 <> 而不是 "" 的形式,即使它们不是标准库文件。我的编译器无法识别它们并返回错误“找不到文件”

问题的一个示例位于以下标题中:

#ifndef _ga_ga_h_
#define _ga_ga_h_

// Make sure that we get the configuration into each of the galib components
// that will be used.
#include <ga/gaconfig.h>

// These are the headers for all of the genetic algorithm classes.
#include <ga/GASimpleGA.h>
#include <ga/GASStateGA.h>
#include <ga/GAIncGA.h>
#include <ga/GADemeGA.h>
#include <ga/GADCrowdingGA.h>

// Here we include the headers for all of the various genome types.
#include <ga/GA1DBinStrGenome.h>
#include <ga/GA2DBinStrGenome.h>
#include <ga/GA3DBinStrGenome.h>
#include <ga/GABin2DecGenome.h>
Run Code Online (Sandbox Code Playgroud)

我使用 #include …

c++ visual-studio include-path

3
推荐指数
1
解决办法
5561
查看次数

隐式声明函数,无论标头 include 和 ifndef 如何

我有众所周知的错误:

implicit declaration of function 'STLINKReadSytemCalls' [-Wimplicit-function-declaration]
implicit declaration of function 'printf' [-Wimplicit-function-declaration]
incompatible implicit declaration of built-in function 'printf'

Eclipse(更准确地说是 Atollic TrueStudio)友好地补充道:

include '<stdio.h>' or provide a declaration of 'printf'

阅读了数十亿篇关于如何解决这个问题的帖子,似乎三个问题可能会导致这些错误:

  • 函数定义在main之后;
  • 包含使用函数所需的标头
  • #ifndef#define并且#endif没有正确包装头文件

我发现一个帖子,其中有人似乎有这个错误,并在修复它后说 Eclipse 是问题所在。虽然找不到主题,但他的解决方案对我不起作用。这就像单击函数,source -> addincludes

主程序

int main(void) {

    if (STLINKReadSytemCalls() == 1)
        printf("Error in system calls.\n");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

文件处理.c

#include "../header/fileProcessing.h"

int STLINKReadSytemCalls(void) {

    // mainly system calls
}
Run Code Online (Sandbox Code Playgroud)

文件处理.h

#ifndef FILEPROCESSING_H_
#define FILEPROCESSING_H_

#include <stdlib.h> …
Run Code Online (Sandbox Code Playgroud)

c eclipse include-path implicit-declaration

3
推荐指数
2
解决办法
2万
查看次数