This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$lines = []; | |
$handle = fopen('x.txt', "r"); | |
if (!$handle){ | |
exit('error'); | |
} | |
while(!feof($handle)) { | |
$line = trim(fgets($handle)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 生成mysql数据字典 | |
*/ | |
// 配置数据库 | |
$database = array(); | |
$database['DB_HOST'] = '127.0.0.1'; | |
$database['DB_NAME'] = 'test'; | |
$database['DB_USER'] = 'testuser'; | |
$database['DB_PWD'] = '123456'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php.ini (php 5.6) | |
; add by zs | |
zend_extension=xdebug.so | |
xdebug.trace_output_dir = /tmp/traces | |
;代码跟踪日志文件格式 | |
xdebug.trace_output_name = trace.%c.%p | |
;;trace中显示函数的参数值,这个很有用,待会细说 | |
xdebug.collect_params = 4 | |
xdebug.collect_includes = On | |
xdebug.collect_return = On |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function zsExceptionHandler(\Exception $e) | |
{ | |
$logData = '__________Start_____________'.PHP_EOL; | |
$logData .= '↓↓↓'.date('Y-m-d H:i:s').PHP_EOL; | |
$logData .= '↓↓↓ Message'.PHP_EOL; | |
$logData .= $e->getMessage().PHP_EOL; | |
$logData .= '↓↓↓ Code'.PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mb_convert_encoding($str, 'utf-8', 'GBK,UTF-8,ASCII'); | |
//可以用curl抓个GBK UTF8的来测试下 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// zend2 DB Mysql | |
$oSelect = new Select(); | |
$oSelect->columns(array('status')) | |
->from($this->tableName) | |
->where(array('sns_union_id = ?' => $snsUnionId, 'sns_type = ?' => $snsType)) | |
->limit(1); | |
$draftArr = $this->executeSelect($oSelect); | |
$draftObj = current($draftArr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace A\B\C; | |
class Exception extends \Exception {} | |
$a = new Exception('hi'); // $a is an object of class A\B\C\Exception | |
$b = new \Exception('hi'); // $b is an object of class Exception | |
$c = new ArrayObject; // fatal error, class A\B\C\ArrayObject not found | |
//http://php.net/manual/en/language.namespaces.fallback.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo "This is my first gist"; |