我试图用rsync将项目复制到我的服务器.我在一个子目录中有项目特定的安装脚本
项目/规格/安装/ PROJECT1
我想要做的是排除项目/规范目录中的所有内容,但项目特定的安装目录:project/specs/install/project1.
rsync -avz --delete --include=specs/install/project1 \
--exclude=specs/* /srv/http/projects/project/ \
user@server.com:~/projects/project
Run Code Online (Sandbox Code Playgroud)
但是像这样,specs目录的内容被排除,但是不包含install/project1目录.
我尝试了一切,但我似乎并没有让这个工作
您好我想问你,如果有人知道如何在Makefile中添加头文件的目录以避免错误*.h找不到,我试过这个选项但不起作用:
INC_PATH := -I /directory/to/add
Run Code Online (Sandbox Code Playgroud) 我有一个需要包含此文件的cron作业:
require '../includes/common.php';
Run Code Online (Sandbox Code Playgroud)
但是,当它通过cron作业(而不是我的本地测试)运行时,相对路径不起作用.cron作业运行以下文件(在实时服务器上):
/home/username123/public_html/cron/mycronjob.php
Run Code Online (Sandbox Code Playgroud)
这是错误:
Fatal error: require(): Failed opening required '../includes/common.php'
(include_path='.:/usr/lib/php:/usr/local/lib/php') in
/home/username123/public_html/cron/mycronjob.php on line 2
Run Code Online (Sandbox Code Playgroud)
使用与cron作业相同的绝对格式,common.php将位于
/home/username123/public_html/includes/common.php
Run Code Online (Sandbox Code Playgroud)
这是否意味着我必须用以下代码替换我的第2行:
require '/home/username123/public_html/includes/common.php';
Run Code Online (Sandbox Code Playgroud)
?
谢谢!
假设我在C++源文件中有以下代码(字面意思):
// #include <iostream> // superfluous, commented-out
using std::cout;
using std::endl;
int main()
{
cout << "Hello World" << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
即使#include <iostream>被注释掉,我也可以编译这段代码:
g++ -include my_cpp_std_lib_hack source.cpp
Run Code Online (Sandbox Code Playgroud)
my_cpp_std_lib_hack是某个中心位置的文件,其中包含C++标准库的所有文件:
#include <ciso646>
#include <climits>
#include <clocale>
...
#include <valarray>
#include <vector>
Run Code Online (Sandbox Code Playgroud)
当然,我可以为我关心的所有编译器(即MS Visual Studio和其他一些编译器)使用适当的编译选项,并且我还使用预编译的头文件.
使用这样的hack给了我以下优点:
#include当我想要的是添加一些调试输出时,无需添加sstd::max声明的所有时间所以我想知道:我在这里做错了吗?
在编写大型项目时,这个黑客会破坏吗?
也许其他人都已经使用过这个,没有人告诉过我?
我有一个导航栏,图像和标题,我将在我的网站的每个页面中包含,所以我想使用php include在几个页面中引用此代码.但是,我认为我的语法可能有问题,或者因为它在加载时没有呈现任何内容.以下是一些代码段:
<!-- sample page --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<?php include ('headings.php'); ?>
</head>
<body>
<?php include ('navbar.php'); ?>
<?php include ('image.php'); ?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
navbar.php
<?php
echo '<ul id="nav">
<li>
<a href="Home.html">Home</a>
</li>
<li>
<a>About Me</a>
<ul>
<li>
<a href="Career.html">Career</a>
</li>
<li>
<a href="Coding.html">Coding</a>
</li>
<li>
<a href="Personal.html">Personal</a>
</li>
</ul>
</li>
<li>
<a href="Travels.html">Travel</a>
</li>
<li>
<a href="Contact.html">Contact</a>
</li>
</ul>';
?>
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
在我的PHP网站和各种嵌套目录的各个页面上,我想在相对于根的路径中包含特定文件.
我可以在这两个页面上放置什么单一命令......
http://www.example.com/pageone.php
http://www.example.com/somedirectory/pagetwo.php
...包括此页面:
http://www.example.com/includes/analytics.php
这不起作用:
<?php include('/includes/analytics.php'); ?>
Run Code Online (Sandbox Code Playgroud)
这是在Windows上的IIS中托管吗?
我一直试图在student.h文件中包含一个名为"student"的结构,但我不太清楚如何做到这一点.
我的student.h文件代码完全包含:
#include<string>
using namespace std;
struct Student;
Run Code Online (Sandbox Code Playgroud)
而student.cpp文件完全由以下内容组成:
#include<string>
using namespace std;
struct Student {
string lastName, firstName;
//long list of other strings... just strings though
};
Run Code Online (Sandbox Code Playgroud)
不幸的是,使用的文件#include "student.h"会出现很多错误
error C2027: use of undefined type 'Student'
error C2079: 'newStudent' uses undefined struct 'Student' (where newStudent is a function with a `Student` parameter)
error C2228: left of '.lastName' must have class/struct/union
Run Code Online (Sandbox Code Playgroud)
编译器(VC++)似乎无法识别"student.h"中的struct Student?
如何在"student.h"中声明struct Student,以便我可以#include"student.h"并开始使用struct?
我想知道有没有办法在仅使用html的另一个html中包含一些html内容?
PHP的替代品
<?php include("file.php"); ?>
Run Code Online (Sandbox Code Playgroud)
这可能吗?
编辑:
这引起了一些混乱,我需要的是"几乎是一个html标签",它具有在另一个中包含html文档的功能.
.cpp文件而不是.h文件?翻译单位是否受到影响? .h文件和.cpp文件中都需要它,我应该将它包含在.h文件中吗?这有关系吗? stdafx.h)中,例如std和第三方库,这是一个好习惯吗?我自己的文件怎么样,我应该在stdafx.h创建它们的过程中将它们包含在文件中? // myClass.h
#include <string>
// ^-------- should I include it here? --------
class myClass{
myClass();
~myClass();
int calculation()
};
// myClass.cpp
#include "myClass.h"
#include <string>
// ^-------- or maybe here? --------
[..]
int myClass::calculation(){
std::string someString = "Hello World";
return someString.length();
}
// stdafx.h
#include <string.h>
// ^--------- or perhaps here, and then include stdafx.h everywhere? -------
Run Code Online (Sandbox Code Playgroud)