<?php
function ismain(){
$debug = debug_backtrace();
if(PHP_SAPI === 'cli' && count($debug)==1 && $debug[0]["function"]==__FUNCTION__){
return true;
}
return false;
}
if ( ismain()){
// do something...
}
<?php
function ismain(){
$debug = debug_backtrace();
if(PHP_SAPI === 'cli' && count($debug)==1 && $debug[0]["function"]==__FUNCTION__){
return true;
}
return false;
}
if ( ismain()){
// do something...
}
project.name = news
project.default_charset = utf-8
server.index = 192.168.219.129:8383
server.search = 192.168.219.129:8384
[pid]
type = id
[title]
type = title
[category_id]
index = self
type = string
tokenizer = split(,)
[new_cat_id]
index = self
type = string
tokenizer = full
numeric
时, 仅用于区间检索, 否则使用string
self
时, 可以用 field:xxx
来检索指定的field
字段full
时, 字段作为一个整体检索词(例如ID); 为split(,)
时, 将按照,
分割内容 composer require hightman/xunsearch
require_once __DIR__ . '/vendor/autoload.php';
$xs = new XS('./test/test.ini');
//创建索引对象
$index = $xs->index;
//创建搜索对象
$search = $xs->search;
./util/Indexer.php --clean <project_name>
//创建索引对象$index后
$index->clean();
brew reinstall <modules> --build-from-source
if (function_exists('curl_file_create')) { // php 5.5+
$cFile = curl_file_create($file_name_with_full_path);
} else { //
$cFile = '@' . realpath($file_name_with_full_path);
}
$post = array('extra_info' => '123456','file_contents'=> $cFile);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
curl_close ($ch);
常用扩展可以使用php-pear来安装,但是php自带的扩展并不行,例如'curl' 'sysvchm'
#获取php-config路径
#whereis php-config
cd <php编译文件目录>/ext/curl/
phpize
./cinfigure -with-php-config=<php-config路径>
make && make install
cp module/curl.so <php扩展目录>
重启php进程
Copyright © 2016 yjiang's cake