作者:matrix 被围观: 1,480 次 发布时间:2013-11-03 分类:零零星星 | 无评论 »
这是一个创建于 3224 天前的主题,其中的信息可能已经有所发展或是发生改变。
TIME: 20190120 工作几年回过头来发现最近真理这篇post都是17年4月份了。看来工作之后真是进步或许没时间亦或变懒,不为简单函数做笔记。
大多都外链工具所用到的,整理整理,以便后用。
使用@符号也可以
preg_match_all ("/share_uk=(.*?)share/",
//使用preg_match_all正则匹配数据并保存到$titleList数组中
$ukidList0表示第1数组【第一个括弧的值,如.*?】匹配到的字符串
废弃的eregi函数同理,传说使用preg函数更高效
strpos 区别大小写strpos查找成功后则是返回的是位置。因为位置有可能是0,所以判断查找失败使用===false更合适。
zhuaqian=strpos( titleList0,"title>"); zhuahou=strpos( titleList0,"_免费高速下载|百度云 网盘-分享无限制"); xinzhi=substr( titleList0,6,
取得当前url的页面url。
http://127.0.0.1/xxx.[php](https://www.hhtjim.com/tag/php)?st=http://hhtjim.com
返回:/xxx.php?st=http://hhtjim.com
$NOWstr = 'http://' .$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];//由于$_GET['url']取url不完整
$NEWstr=explode('?url=',$NOWstr);
$quurl = $NEWstr[1];
作用大大的有。
示例代码:
function curl_get($url,$post=false,$carry_ua=true){
$ch=curl_init($url);
if($carry_ua){
curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent:Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16'));
}
if ($post) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$get_url = curl_exec($ch);
curl_close($ch);
return $get_url;
}
不懂,再保留另外的
$curlPost=’http://songtaste.com/time.php’;
$ch = curl_init();//初始化curl
curl_setopt($ch,CURLOPT_URL, $url);//提交到指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);//运行curl
curl_close($ch);
print_r($data);//输出结果
模拟POST提交数据
$post_data = array('nid' => '13714766852756201', 'shorturl' => 'QeEWZNzPansuQ');
$url='http://ajy8hpcasy.l17.yunpan.cn/share/downloadfile/';
$_REFERER='http://ajy8hpcasy.l17.yunpan.cn/lk/QeEWZNzPansuQ';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_REFERER,$_REFERER);
ob_start();
curl_exec($ch);
$result = ob_get_contents() ;
ob_end_clean();
echo $result;
header("location: http://hhtjim.com");//跳转到http://hhtjim.com
list(shareid, uk) = array_slice(
//数组中有shareid, uk元素,让元素名最为变量名字。
//$res为总的数组,1为规定取出元素的开始位置。2为需要返回的数组数量。
define("GREETING","Hello world!");
//常量名为GREETING,值为"Hello world!
条件表达式e1?e2:e3,若e1为真(非0),则此表达式的值为e2的值;若为假,则表达式的值为e3
例如:
preg_match('|Location: (.+)\r|', $src, $res);
$songurl = $res ? $res[1] : exit(" error!");
示例:
$rt='{"errno":0,"errmsg":"\u64cd\u4f5c\u6210\u529f","data":{"downloadurl":"http:\/\/wsdl25.yunpan.cn\/share.php?method=Share.download&fhash=119f736a936d62396d7dd71ff8fb7d187d69d3d9&xqid=23620387&fname=%E8%AF%B4%E6%98%8E.doc&fsize=211968&nid=13754589643979953&cqid=157ddad976b9aa811591ed43134891f7&st=48ea3770079bce5360f952cff1dc9d29&e=1382784599&dt=25.1291649b2f9ed61380291c5c0d711ca9","params":[]}}';
$obj = json_decode($rt);
$dll=$obj->data->downloadurl;
echo $dll;
示例二:
json数据:
{
"songs": [{
"score": 100,
"copyrightId": 0,
"mvid": 0,
"mp3Url": "http://m1.music.126.net/fG44YGce-id8VZ9LjQIPpQ==/1069824813834035.mp3"
}],
"code": 200
}
php处理:
$eo='上面的json数据';
$obj=json_decode($eo,true);
echo $obj['songs'][0]['mp3Url'];
结果返回:
h t t p : / /m1.music.126.net/fG44YGce-id8VZ9LjQIPpQ==/1069824813834035.mp3
对于数组中的每个元素,键名用于变量名,键值用于变量值。
substr_replace(P, v,9,1);//(替换第10位的数字为
echo <<<tem
<script>alert("输入的留言内容太长!");history.go(-1);</script>
tem;
tem是任意字符,<<<后的tem标记着开始。必须以 tem; 结尾,另起一行顶格(前面无空格)书写,否则会报错。
echo <<<'tem'
$a str
tem;
添加单引号 就不会解析里面的变量
函数计算字符串的 MD5 散列,第二的参数规定十六进制或二进制输出格式。
创建一个包含变量名和它们的值的数组:
$firstname = "Bill";
$lastname = "Gates";
$age = "60";
$result = compact("firstname", "lastname", "age");
print_r($result);
extract() 正好相反
陆续添加整理。。。