用Aptana Studio 3进行PHP开发

背景

之前一直都是,在本地建立的apache服务器的localhost中,去运行用Notepad++编写出来的PHP代码。

现在装了Aptana Studio 3,打算接着去试试,看看能否直接使用其去编写,运行,调试php代码。


1.直接打开了本地写好的一个php文件,点击运行,结果是,运行了,当前的,之前打开的Python项目:

run php code but outpu cur py prj

所以,貌似没法直接运行。

2.所以再去重新创建一个php项目:

file new php project

填写好对应的信息后,点击完成:

input php name set path use php 5.3.x then finish

然后就可以生成对应的php项目了:

genarated php project

然后去新建一个文件,此处选择从模板中建立:

new from template php php template

new php file name

new generated php file

改为所需的代码:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
Function:
【记录】尝试在PHP中支持Proxy代理去实现网络抓取
 
Date:       2013-01-11
Author:     Crifan
Contact:    admin (at) crifan (dot) com
*/
 
//用Php检测代理IP是否可用
$daili = '190.147.98.147:80' ;
curl_string( 'http://www.baidu.com' , $daili );
 
function curl_string ( $url , $proxy )
{
     $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh- CN; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 FirePHP/0.2.1" ;
     $ch = curl_init();
     curl_setopt ( $ch , CURLOPT_PROXY, $proxy );
     curl_setopt ( $ch , CURLOPT_URL, $url ); //设置要访问的IP
     curl_setopt ( $ch , CURLOPT_USERAGENT, $user_agent ); //模拟用户使用的浏览器
     curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, 1 ); // 使用自动跳转 
     curl_setopt ( $ch , CURLOPT_AUTOREFERER, 1 ); // 自动设置Referer 
     curl_setopt ( $ch , CURLOPT_COOKIEJAR, 'cookie.txt' );
     curl_setopt ( $ch , CURLOPT_HEADER, 1);
     curl_setopt ( $ch , CURLOPT_RETURNTRANSFER, 1);
     //curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt ( $ch , CURLOPT_TIMEOUT, 5);
     $result = curl_exec( $ch );
     preg_match( "/百度一下/isU" , $result , $baidu_okk );
     if ( $baidu_okk [0]== '' )
     {
         echo 'no' ;
     } else {
         echo 'ok' ;Txtdb_a( 'daili.txt' , $proxy . "\r\n" ); //将合格的代理IP记录在文件中
     }
     curl_close( $ch );
     return $result ;
}
  ?>

 

copied php code

然后去想办法运行。

3.折腾半天,暂时没搞定。

其中遇到一些错误,详见:

【已解决】Aptana Studio 3中运行PHP代码出错:No PHP executables defined; The current debugger does not have any defined PHP executables. Please define a PHP executable location before continuing

 

4.接着,又遇到另外的错误:

【未解决】Aptana Studio 3中Run as PHP Script出错:an internal error occurred during java.lang.NullPointerException

 

5.然后又遇到问题了。

【未解决】Aptana Studio 3中Run as PHP server出错:failed to launch on PHP server, Could not create a default server for the launch

 

6.另外,此处,确定当前的:

http://127.0.0.1/

http://localhost/

都是一样的,可以正常运行的。

只是路径不对。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值