简体   繁体   English

为什么eclipse不会运行我的php文件?

[英]Why won't eclipse run my php file?

I'm running eclipse galileo (5.5) with PDT 2.1.2. 我用PDT 2.1.2运行eclipse galileo(5.5)。 I have "PHP Executables" pointed to /usr/bin/php, which outputs: 我有“PHP Executables”指向/ usr / bin / php,它输出:

$:/usr/bin$ php -version
PHP 5.2.6-3ubuntu4.2 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21 2009 19:14:44) 
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

I have created a new PHP project with a very basic php file named "newfile.php": 我创建了一个新的PHP项目,其中包含一个名为“newfile.php”的非常基本的php文件:

<?php
echo "Hello";
?>

When I right click the file and select "Run As->PHP Script", absolutely nothing happens! 当我右键单击该文件并选择“Run As-> PHP Script”时,绝对没有任何反应! I expect the Console to gain focus and show my output, but . 我希望控制台获得焦点并显示我的输出,但是。 . . nothing! 没有! No output in the console, no error . 控制台中没有输出,没有错误。 . . nada. 缥缈。

I think I've got eclipse pointed to the correct php file. 我想我已经让eclipse指向正确的php文件。 So, what am I doing wrong? 那么,我做错了什么?

Any help is appreciated! 任何帮助表示赞赏!

From you console, I see that you have php installed from Zend Engine product. 从你的控制台,我看到你已经从Zend Engine产品安装了php。 You need to configure PHP executables in Window->Preferences->PHP->PHP Executables. 您需要在Window-> Preferences-> PHP-> PHP Executables中配置PHP可执行文件。 Difine right path of php and php.ini files in the form. 在表单中区分php和php.ini文件的正确路径。

This is a shot in the dark, but try putting the shebang line in at the top of your file. 这是一个黑暗中的镜头,但尝试将shebang线放在文件的顶部。 Proper shell scripting dictates that it needs to be there, and eclipse/pdt might care. 适当的shell脚本要求它需要存在,eclipse / pdt可能会关心。

#!/usr/bin/php
<?php
//.....rest of your file
?>

Other possibilities: 其他可能性:

-make sure the file has focus in the editor when 'run as' - 当'run as'时,确保文件在编辑器中具有焦点

-check project specific settings - 检查项目特定设置

还尝试右键单击文件结构树中的文件,但是该文件的源代码并选择相同的文件。

尝试作为网页运行,因为如果你有php它意味着你有apache,所以eclipse只会打开你的网址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM