❶ centos 7.2 系統 php7.0.12的 curl 擴展怎麼開啟
curl是一個廣泛使用的用來上傳和下載的命令行工具,當然嚴格來講,它還可以有別的用途。對於測試來講,它是Web相關測試非常實用的工具,包括debugging,使用起來非常方便。
下面直接進入主題:
1、直接進入到php源碼包中找到原先安裝PHP的源碼包文件①;
2、直接進入/usr/package/php-7.1.10/ext/curl目錄②;
cd /usr/package/php-7.1.10/ext/curl
3、通過phpize工具生成configure文件③;
/usr/local/php/bin/phpize
4、將安裝的軟體進行配置,檢查當前的環境是否滿足要安裝軟體的依賴關系④;
./configure --with-php-config=/usr/local/php/bin/php-config
5、編譯程序並安裝文件;
make &&make install
6、在php的配置文件php.ini最後一行添加extension=curl.so即可。
相關解釋(帶圓圈的數字編號)可參考:https://panxu.net/article/8392.html
❷ php 關於intval函數!
第二個參數是指定第一個參數的進制,比如intval("12",5)就是把「12」當成5進制的數,然後把這個5進制的數轉換成10進制整數。
intval("12",5) = 7; (5進制的12=10進制7)
intval("1011",2) = 11; (2進制的1011=10進制11)
❸ php輸出年齡段,最小年齡12,最大60歲,顯示如 12歲-24歲,25歲-36歲....
<?php
/**
*CreatedbyPhpStorm.
*User:[email protected]
*Date:2017/7/13
*Time:12:36
*/
classTestAge
{
/**
*@param$youngAge最小年齡
*@param$oldAge最大年齡
*@param$ageRange分段年齡區間
*@returnarray
*/
publicfunctiongetAgeToArray($youngAge,$oldAge,$ageRange){
$a=array();
$c=array();
$yage=$youngAge;
$ageRangeNum=ceil(($oldAge-$youngAge)/$ageRange);
for($youngAge;$youngAge<=$oldAge;$youngAge++){
array_push($a,$youngAge);
}
for($i=1;$i<=$ageRangeNum;$i++){
foreach($aas$k=>$v){
if($a[$k]<$yage+$ageRange*$i&&$a[$k]>=$yage+$ageRange*($i-1)){
$c[$i][]=$v;
}
}
}
return$c;
}
}
$ob=newTestAge();
$result=$ob->getAgeToArray(12,60,5);
var_mp($result);
❹ php 自動計算12生肖
<?php
//2002/10/23-->出生年月
/*
計算12個星座
計算12個生肖
計算年齡
*/
class timeage
{
public $y = 0;
public $m = 0;
public $d = 0;
public $age = 0;
public $time = 0;
public function __construct($time)
{
$this->time = $time;
$this->y = date('Y',$this->time);
$this->m = date('m',$this->time);
$this->d = date('d',$this->time);
}
public function getage()
{
$this->age = time() - $this->time;
$this->age = $this->age/60/60/24/365;
return (int)$this->age;
}
public function getconstellation()
{
switch ($this->m)
{
case 1:
if ($this->d < 19)
{
$this->constellation = '摩羯座';
return $this->constellation;
}
else
{
$this->constellation = '水瓶座';
return $this->constellation;
}
break;
case 2:
if ($this->d < 18)
{
$this->constellation = '水瓶座';
return $this->constellation;
}
else
{
$this->constellation = '雙魚座';
return $this->constellation;
}
break;
case 3:
if ($this->d < 20)
{
$this->constellation = '雙魚座';
return $this->constellation;
}
else
{
$this->constellation = '白羊座';
return $this->constellation;
}
break;
case 4:
if ($this->d < 19)
{
$this->constellation = '白羊座';
return $this->constellation;
}
else
{
$this->constellation = '金牛座';
return $this->constellation;
}
break;
case 5:
if ($this->d < 20)
{
$this->constellation = '金牛座';
return $this->constellation;
}
else
{
$this->constellation = '雙子座';
return $this->constellation;
}
break;
case 6:
if ($this->d < 21)
{
$this->constellation = '雙子座';
return $this->constellation;
}
else
{
$this->constellation = '巨蟹座';
return $this->constellation;
}
break;
case 7:
if ($this->d < 22)
{
$this->constellation = '巨蟹座';
return $this->constellation;
}
else
{
$this->constellation = '獅子座';
return $this->constellation;
}
break;
case 8:
if ($this->d < 22)
{
$this->constellation = '獅子座';
return $this->constellation;
}
else
{
$this->constellation = '處女座';
return $this->constellation;
}
break;
case 9:
if ($this->d < 22)
{
$this->constellation = '處女座';
return $this->constellation;
}
else
{
$this->constellation = '天秤座';
return $this->constellation;
}
break;
case 10:
if ($this->d < 23)
{
$this->constellation = '天秤座';
return $this->constellation;
}
else
{
$this->constellation = '天蠍座';
return $this->constellation;
}
break;
case 11:
if ($this->d < 22)
{
$this->constellation = '天蠍座';
return $this->constellation;
}
else
{
$this->constellation = '射手座';
return $this->constellation;
}
break;
case 12:
if ($this->d < 20)
{
$this->constellation = '射手座';
return $this->constellation;
}
else
{
$this->constellation = '摩羯座';
return $this->constellation;
}
break;
}
}
public function getzodiac()
{
$this->animals = array('鼠', '牛', '虎', '兔', '龍', '蛇','馬', '羊', '猴', '雞', '狗', '豬');
$this->zodiac = ($this->y - 1900) % 12;
return $this->animals[$this->zodiac];
}
}
$age = strtotime('1993-07-25');
echo $age;
$a = new timeage($age);
echo '<br>';
echo $a->y;
echo '<br>';
echo $a->m;
echo '<br>';
echo $a->d;
echo '<br>';
echo $a->time;
echo '<br>';
echo $a->age;
echo '<br>';
echo $a->getage();
echo '<br>';
echo $a->getconstellation();
echo '<br>';
echo $a->getzodiac();
//沒事干替你寫了個全部的功能函數 寫代碼類 記得給好評
❺ <php $arr = array(5 => 1, 12 => 2,2 => 3); $arr[] = 56; 請問此處中括弧中的鍵名是3嗎$arry[3]=56.
<?php $arr = array(5 => 1, 12 => 2,2 => 3); $arr[] = 56; 請問此處中括弧中的鍵名是3嗎?
這里不是3 而是13,因為 array(5 => 1, 12 => 2,2 => 3) 裡面,關聯數組 數字ID鍵名最大是12,
$arr[] = 56; 這里再加一個鍵,就是13了。