最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】用Aptana Studio 3进行PHP开发

PHP crifan 3370浏览 0评论

背景

之前一直都是,在本地建立的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

改为所需的代码:

<?php
/*
Function:
【记录】尝试在PHP中支持Proxy代理去实现网络抓取
https://www.crifan.com/record_php_crawl_website_using_proxy

Date:       2013-01-11
Author:     Crifan
Contact:    admin (at) crifan (dot) com
*/

//http://blog.sjzycxx.cn/post/413/
//用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/

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

只是路径不对。

转载请注明:在路上 » 【记录】用Aptana Studio 3进行PHP开发

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.165 seconds, using 22.14MB memory