首页 > 编程技术 > php

mac系统下怎么安装多个php并自由切换

发布时间:2017-7-6 23:49

Mac系统也是现在使用比较多的系统,今天文章要给大家介绍的是mac系统下怎么安装多个php并自由切换,还不知道具体方法的下面一起来看看。

最近工作中遇到一个问题,需要实现在mac系统下安装多个php并实现自由切换,通过查找相关的资料找到了解决的方法,所以想着总结下来,方便大家和自己学习参考,下面话不多说,来看看的介绍吧。

一、安装多版本php

$ brew install php54 

$ brew install php70

如果安装报以下错误:

Error: Cannot install homebrew/php/php70 because conflicting formulae are installed.

php54: because different php versions install the same binaries.

Please `brew unlink php54` before continuing.

解决办法有二种:

1、brew unlink php54

2、删除/usr/local/bin,下面有关php的软链接

上面2种方法,目的是一样的。

二、安装切换工具php-version

$ brew install php-version 

$ source $(brew --prefix php-version)/php-version.sh 

$ php-version 

 5.4.45 

* 7.0.17 

$ php-version 5.4.45 //切换到5.4 

$ php-version 

* 5.4.45 

 7.0.17 

$ echo "source $(brew --prefix php-version)/php-version.sh" >> ~/.bash_profile

 代码如下复制代码

本文介绍了PHP+JavaScript实现无刷新上传图片的教程,非常实用,有兴趣的同学快来看看吧

html文件代码

 

 代码如下 复制代码

<!-- ajax文件上传开始 -->

<scripttype="text/javascript"src="/imageupload/jquery-1.10.2.min.js"></script>

<scripttype="text/javascript"src="/imageupload/layer/layer.js"></script>

<scripttype="text/javascript"src="/imageupload/ajaxupload.js"></script>

<!--ajax文件上传结束-->

<!--上传文件按钮列表开始-->

<inputid="requesturl"type="hidden"value="{:U('admin/upload/uploadfile')}"/>

<inputid="ajaxuploadfile"type="file"onchange="filechange()"/>

<inputid="filepathurl"type="hidden"value=""/>

<inputtype="button"value="第一张"pathurl="./Uploads/admin/trailer/"class="uploadclass"/>

<inputtype="button"value="第二张"pathurl="./Uploads/admin/fdfdfd/"class="uploadclass"/>

<inputtype="button"value="第三张"pathurl="./Uploads/admin/cdcdfd/"class="uploadclass"/>

<!--上传文件按钮列表结束-->

 

php文件代码

 

 代码如下 复制代码

/**

* 文件上传方法

*/

publicfunctionuploadfile(){

//单文件上传

$upload=new\Think\Upload();// 实例化上传类

$upload->maxSize = 100000000 ;// 设置附件上传大小

$upload->exts =array('jpg','gif','png','jpeg');// 设置附件上传类型

$url=$_POST['filepathurl'];

if(!file_exists($url)){

mkdir($url,0777,true);

}

$upload->rootPath =$url;// 设置附件上传根目录

// 上传单个文件

$info=$upload->uploadOne($_FILES['postfilename']);

if(!$info) {

echojson_encode(array('bool'=>false,'error'=>$upload->getError()));

}else{

$path=$info['savepath'].$info['savename'];

echojson_encode(array('bool'=>true,'path'=>$path));

}

}

 

小编推荐的这篇文章介绍了PHP编辑器PhpStrom运行缓慢问题的解决办法,有兴趣的同学快来看看吧

最近在使用phpstorm开发项目的时候,在加载文件运行时,不管有多大,如果项目文件数据比较多的话,都能够让phpstorm卡到死机。其中调整过内存设置,关闭过动态提示,使用过phpstorm的安全模式,都不能解决卡的问题。中间也试过放弃phpstorm,改用其他IDE开发。但都没有phpstorm那么好用。没办法,在国内的百度无法找到解决方案,只能出去找了。

最终在一个国外论坛里,看到不一样的回答。只要修改两个Java虚拟机参数,就彻底解决了卡的问题了。

操作步骤如下:

1.找到phpstorm.vmoptions文件,使用记事本打开。

2.添加以下两行代码:

-Dawt.usesystemAAFontSettings=lcd

-Dawt.java2d.opengl=true

3.保存退出。

思考:

phpstorm是使用JAVA开发的。由于IDE提供源文件关键字渲染功能,我们对文件的任何编辑或移动鼠标,都会触发渲染操作。而phpstorm默认的JAVA环境并没有利用机器的硬件加速技术去实现实时渲染,因此当然会让系统卡死。而只要在JAVA环境中让系统默认使用硬件加速,就可以解决占用系统资源过大,让phpstorm卡的问题了。

现在又可以使用回phpstorm的熟悉环境了。

本文介绍了如何离线执行php任务,非常实用,有兴趣的同学快看看吧

直接上代码,主要函数

ignore_user_abort(true);

这个函数忽略了终端被关闭(打开的网页被关闭),后面

getfiles()这函数是执行采集任务的自定义函数,后面又配置了下路径

打开写好的页面,关闭,后面发现任务都能执行完成,有兴趣的可以试试。

 代码如下 复制代码

<?php

//设置忽略是否关闭终端窗口

ignore_user_abort(true);

ini_set('max_execution_time','0');

//采集页面函数,看不懂执行百度curl php

functiongetfiles($url,$name){

  $name=$name.".txt";

  $ch= curl_init("$url");

  $fp=fopen("$name","w");

  curl_setopt($ch, CURLOPT_FILE,$fp);

  curl_setopt($ch, CURLOPT_HEADER, 0);

  curl_exec($ch);

  curl_close($ch);

  fclose($fp);

  sleep(5);

  echo'<script>window.close();</script>';

}

//配置需要采集的页面路径数组

$urls=array(

  'http://www.cnblogs.com/jianqingwang/p/6373168.html',

  'http://www.cnblogs.com/jianqingwang/p/6148644.html',

  'http://www.61916.com/news_view_2423.html',

  'http://blog.sina.com.cn/s/blog_8e326c350102w1ah.html',

  'http://www.w3school.com.cn/php/func_misc_ignore_user_abort.asp',

  'http://xinwen.eastday.com/a/170219205305597.html',

  'http://society.huanqiu.com/article/2017-02/10162630.html?from=bdwz',

  'http://www.cankaoxiaoxi.com/roll10/bd/20170220/1699670.shtml',

  'http://news.china.com/socialgd/10000169/20170220/30266284.html',

  'http://news.k618.cn/society/201702/t20170220_10368740.html',

  'http://fj.qq.com/a/20170218/029521.htm'

);

//遍历数组

foreach($urlsas$key=>$val){

  getfiles($val,$key);

}

?>

标签:[!--infotagslink--]

您可能感兴趣的文章: