标签: include

php包括打印'1'

可能重复:
php包含打印1

$html = '<div class="subscribe_user"><span id="question1"><a href="#" id="subscribe_link" data-category="'.$category.'">
                Subscribe to comments made on '.$category.'</a></span></div>' . include(SUBSCRIBE_USER_BASE_DIR . '/includes/av_subscribe_form.php');
Run Code Online (Sandbox Code Playgroud)

这个包含文件是带有一些PHP变量的HTML表单.

我通过插件返回$ html:

return $html;
Run Code Online (Sandbox Code Playgroud)

但我无法摆脱输出附加的'1'.当然这意味着它输入文件是成功的,但我该如何解决这个问题呢?

php include

2
推荐指数
1
解决办法
1425
查看次数

从远程服务器包含PHP文件时,常量不会"填充"

我有以下问题:我有一个PHP文件(standards.php),其中包含以下语句:

define('CONSTVAR', '/path/');
Run Code Online (Sandbox Code Playgroud)

现在,我有另一个名为的文件untitled.php,其中包含:

include ('standards.php');
echo CONSTVAR;
Run Code Online (Sandbox Code Playgroud)

这将导致页面/path/显示常量的值.

到目前为止一切都很好.

但是,当我把它standards.php放在我的另一个网站上并尝试从那里(使用include('http://mysite.eu/core/standards.php');命令)包含它时,它不起作用.常量保持为空,我也得到以下错误

警告:main(http://mysite.eu/core/standards.php)[function.main]:无法打开流:第28行/home/www/this.nl/core/untitled.php中的权限被拒绝

警告:main()[function.include]:无法打开"http://mysite.eu/core/standards.php"(include_path ='.:/ usr/local/php4/lib/php')/第28行的home/www/this.nl/core/untitled.php

allow_url_include也启用allow_url_fopen了.当我输入standards.php浏览器的完整URL时,我得到一个页面结果,所以这不是没有访问权限的问题,对吧?

这可能是什么问题?为什么常量应该是全局的,而不是从远程服务器包含时"继承"?

php const include remote-server

2
推荐指数
1
解决办法
1689
查看次数

如何将php文件调用为div?

我正在尝试重新加载特定的div

$("#captcha").html('<?php echo 'abc';?>'); // just as test - works well
Run Code Online (Sandbox Code Playgroud)

因为div内容要大得多,我试过:

$("#captcha").html('<?php include 'myFile.php';?>'); // doesn't work
Run Code Online (Sandbox Code Playgroud)

如何将.php文件中的代码调用为div?

javascript php jquery include

2
推荐指数
1
解决办法
5206
查看次数

使用PHP包含时如何避免空格?

我有一些文件需要包含在几个页面中,所以,我使用类似的东西

<html>
<head>
<title>This is a webpage</title>
</head>
<body>
<div>Hello, this is a webpage</div>
<?php include("header.html");?>
<div>Some more text.</div>
<?php include("BlockToInclude.php");?>
<div>Even more text.</div>
<?php include("footer.html");?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

问题是每个include();我在包含的内容之前得到一个20px的空白区域.我通过将第一个包含的块的边距减少20px来解决这个问题,但我更喜欢避免这个空间而不是补偿它的东西.另外,我是PHP的新手,这是一种正常的行为还是我应该找一些我做错的事情?

更新:我检查了生成的代码,在我调用insert();函数的每个位置,它看起来都是一个不在原始文件中的陌生人角色(也不是调用者或包含的).我将代码从Firefox代码查看器(在哪里看不到)复制到我的编辑器(Windows中的RJ TextEd),它在框中显示为问号; 如果我将此代码保存为静态html,则呈现相同,但如果我删除这些字符,则空格会消失.有什么想法吗?

php include

2
推荐指数
1
解决办法
6455
查看次数

如何在C++中正确使用#ifndef #define #endif

我正在开发一个需要以下结构的项目: 在此输入图像描述

2个CPP文件包含类,这些类需要H文件1中的裸函数.类和nakeds需要H文件2中的变量.

我可以拆分CPP文件,以便他们使用2个单独的文件,其中包含nakes和他们需要的变量.但我更喜欢使用这种结构.

看起来编译器跳过#ifndef命令,我对问题进行了测试:

主要:

#include <iostream>

//1>CPPFile2.obj : error LNK2005: "bool Test1" (?Test1@@3_NA) already defined in CPPFile1.obj
//1>CPPFile2.obj : error LNK2005: "bool Test2" (?Test2@@3_NA) already defined in CPPFile1.obj

int main()
{
}
Run Code Online (Sandbox Code Playgroud)

CPPFile 1:

#include <iostream>
using namespace std;

#include "HFile1.h"
Run Code Online (Sandbox Code Playgroud)

CPPFile 2:

#include <iostream>
using namespace std;

#include "HFile2.h"
Run Code Online (Sandbox Code Playgroud)

HFile 1:

#include "HFile2.h"

#pragma once
#ifndef Name1
#define Name1

//Use test1, this workes fine
//Use test2, this workes fine

#endif
Run Code Online (Sandbox Code Playgroud)

HFile 2:

#pragma once
#ifndef Name2
#define Name2 …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors include

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

C++:非内联模板方法的放置

假设我有一个带有方法模板的类:

//file: X.h
class X{

    int x;
    //... more members and non-template functions

    template<typename T>
    void foo(T t){ //Error, cannot define the method here. Declaration is okay
        Y y = ...;
    }
}

//file Y.h
class Y {
    X x;
}
Run Code Online (Sandbox Code Playgroud)

由于循环类依赖(foo的主体依赖于Y和Y依赖于X),我无法定义foo我声明它的方法模板(请不要现在质疑设计).

那么,foo在这种情况下把定义放在哪里?我无法将其他定义放入.cpp文件中,否则链接将失败.

我的解决方案是创建一个新的头文件,例如"X.hpp",只添加模板方法的定义.在这个文件中,我包含"Xh"和"Yh".现在,每当我需要X类时,我只需要包含"X.hpp",它将包含其他必要的h文件.

所以我的问题是:这是正确/最好的方法吗?它以某种方式让我觉得我只有一个单独的方法模板定义的.hpp文件,但它似乎是圆形类型依赖的唯一可行方法.请再次:不要质疑设计,说"最好避免循环类型依赖"或类似的东西.问题是:如果我有这些依赖关系,那么处理单个方法模板的最佳方法是什么.

c++ templates include

2
推荐指数
1
解决办法
225
查看次数

如何找到服务器上Zend的安装位置?

我试图在我的PHP脚本中使用Zend的“ Zend_Service_Amazon”类,但不确定该文件的安装位置。我假设在尝试基于此错误而调用方法之前,需要包括Zend的路径:

Fatal error: Class 'Zend_Service_Amazon' not found in /public_html/path/zend.php on line 3
Run Code Online (Sandbox Code Playgroud)

我知道Zend是根据以下php -v输出安装的:

Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd., and
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
Run Code Online (Sandbox Code Playgroud)

那么,如何找到它的驻留位置以及如何将其包含在我的php脚本中?

如果有什么不同,我正在使用cPanel。

php zend-framework runtime-error include

2
推荐指数
1
解决办法
2197
查看次数

A类需要B类,需要A类及其所有成员

我绝对是一个绝望的案例......使用C++,我已经定义了这两个类:

// Console.hpp
#ifndef CLASS_Console
#define CLASS_Console
#include <iostream>
#include "Window.hpp"

class Console
{
public:
    Window *Win;
    Console(Windows *Win); // Which then does "this->Win = Win;"
    void AppendText(std::string);
    // And some more dozens functions
};
#endif

// Window.hpp
#ifndef CLASS_Window
#define CLASS_Window
#include <iostream>
#include "Size.hpp"

class Window
{
private:
    Console *m_Console;

public:
    Window(); // Which then does "m_Console = new Console(this); m_Console->AppendText("YEAH");"
    Console *getConsole(); // For use by another classes
    Size getSize();
    // And some more Tens and Tens …
Run Code Online (Sandbox Code Playgroud)

c++ recursion class include members

2
推荐指数
1
解决办法
611
查看次数

类中的PHP调用类返回错误:500

我很难在另一堂课上上课.这是设置的一个示例:

的index.php

<?php
   include("functions/userFunctions.php");

   $user = new UserFunctions ();
   $user->validate();
?>
Run Code Online (Sandbox Code Playgroud)

UserFunctions.php

<?php
   include("../db/userDB.php");

   class UserFunctions extends UserDB
   {
       public function GetHello(){
          $this->DBHello();
       }
   }
?>
Run Code Online (Sandbox Code Playgroud)

UserDB.php

<?php
   class UserDB
   {
       public function DBHello(){
          return "Hello"
       }
   }
?>
Run Code Online (Sandbox Code Playgroud)

Chrome返回:HTTP错误500(内部服务器错误):服务器尝试完成请求时遇到意外情况.

这怎么可能不起作用?

php class include

2
推荐指数
1
解决办法
6847
查看次数

为什么我得到未定义的睡眠错误参考?

码:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

struct subscriber {
    char phonenumber[20];
    char name[50];
    float amount;
} s;

void addrecords();
void listrecords();
void modifyrecords();
void deleterecords();
void searchrecords();
void payment();

char get;

int main()
{
    int password;
    int phonenumber;
    char choice;

    system("cls");

    printf
    ("\n\n\n\n\n\n\n\n\n**********************************************************************");
    printf("\n\t\t---WELCOME TO THE TELECOM BILLING MANAGEMENT SYSTEM---");
    printf("\n\t\t****************************************************************");

    Sleep(2000);

    getch();

    system("cls");

    while (1) {
        system("cls");
        printf("\n enter\n A : for adding new records.\n L : for list of records");
        printf("\n M : for modifying records.\n P …
Run Code Online (Sandbox Code Playgroud)

c sleep include

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