douzhongjian0752 2011-08-16 02:13
浏览 57
已采纳

PHP Netbeans中的未知功能 - 如何抑制?

Since I develop on localhost but deploy elsewhere, and since I don't want to have to force my sites to be under a Windows partition's root directory (currently F:\web_dev\htdocs), code like this:

require_once($_SERVER['DOCUMENT_ROOT'] . '/projXY/database/database_common.php');
OdbcExec($sql); // defined in the file above

causes Netbeans to issue a "Warning: unknown function".

Now, I could get round this by using a directory structure like :

F:\project_1  
F:\project_2  

instead of

F:\web_dev_htdocs\project_1  
F:\web_dev_htdocs\project_2  

and then using

require_once('/database/database_common.php');

BUT that imposes constraints on where the end-user an install my site.

Simplest by far would be to tell NetBeans which local directory corresponds to $_SERVER['DOCUMENT_ROOT'], but I can't find a configuration option for that. I am sure this is a common problem. Any suggestions?


Update: NetbBeans v7.0.1

  • 写回答

2条回答 默认 最新

  • dqalnwuci494308 2011-08-16 02:50
    关注

    Simply add the /path/to/projXY/database/ directory to your project's include path. Netbeans will then pick up the files there and use them as code references.

    http://netbeans.org/kb/docs/php/project-setup.html#phpIncludePath

    Addendum

    Relying on $_SERVER['DOCUMENT_ROOT'] is generally a bad idea. For one, it eliminates the ability to run parts of your application via the console / command line.

    You should instead either use configurable, absolute paths to shared libraries or do as in Brandon's answer and use a relative path from __DIR__ (PHP 5.3) or dirname(__FILE__)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿