Categories
Programming/php

[PHP] php 由 pipe (stdin) 讀進檔案 再做處理, 類似 C 的 pipe line 方法

$cnt = 0;
$fp = fopen('php://stdin','r');
while ($line = stream_get_line($fp, 65535, "\n")) {
  echo "LINE #" . (++$cnt) . ": " . $line . "\n";
}

Categories
Programming/php

[memo] php.ini , short_open_tag

php 程式檔案開頭使用 <? 簡寫

須在 php.ini 設定 short_open_tag = On

Categories
Copy_N_Paste Programming/php

[PHP] Native SQLRELAY connect / query sample code

Categories
Programming/php Service System/Linux/Unix*

webhd.monster.tw : Use docker , nextcloud (a dropbox like web storage opensource) …. and docker startup commands …

URL: https://webhd.monster.tw/

Categories
Programming/php Software

[memo] 在 PHP 使用 ssh tunnel 連接遠端的 mysql server

 

Screenshot 2016 02 05 20 42 26

Categories
Programming/php System/Linux/Unix*

PECL PHP REDIS client library phpredis

URL : https://github.com/phpredis/phpredis#classes-and-methods

redis.ini file in /etc/php5/conf.d with the following contents: extension=redis.so

Categories
DATABASE Programming/php

[PHP] Sample code : Berkeley DB , bdb , dba_open , db4 , key-value database ,

$id = dba_open("bdb4_tsid.db", "w", "db4");

if (!$id) { echo "dba_open failed\n"; exit; }

dba_replace("key", "This is an example!", $id);

if (dba_exists("key", $id)) {
        echo dba_fetch("key", $id);
        dba_delete("key", $id);
}

dba_close($id);

Screenshot 2015 05 13 20 28 39

 

 

Screenshot 2015 05 13 20 37 56

 

This is an example!
exist:
This is an example!
---> This is an example!

Categories
Programming/php

PHP Regex Validation of Hexadecimal Values / check hex number

preg_match( '/^[A-F0-9]{15,18}/',$v)

 

Screenshot 2015 05 10 10 53 23

Categories
Programming/php

PHP 的 mktime , time format , 週編號 , week number of year, weeks starting on Monday

Screenshot 2015 02 06 15 31 50

 

1419696000
52 - 2014-12-29 00:00:00
52 - 2014-12-30 00:00:00
52 - 2014-12-31 00:00:00
00 - 2015-01-01 00:00:00
00 - 2015-01-02 00:00:00
00 - 2015-01-03 00:00:00
00 - 2015-01-04 00:00:00
01 - 2015-01-05 00:00:00
01 - 2015-01-06 00:00:00
01 - 2015-01-07 00:00:00

Categories
Copy_N_Paste Programming/php

Protected: PHP exception handling : using try catch exception syntax sample code

This content is password protected. To view it please enter your password below: