標籤:
設定檔在:/etc/php5/$中,不同的模式含有自己的php.ini設定檔。php可以運行於多種模式:cgi、fastcgi、cli、web模組模式等4種;
我現在使用的模式是cli模式,這裡進行一次測試。
在ubuntu下需要安裝sudo apt-get install php5-dev
php應該是php5的連結。
修改config.m4檔案:
my.php檔案內容:
<?php$br = (php_sapi_name() == "cli")? "":"<br>";if(!extension_loaded(‘my‘)) { dl(‘my.‘ . PHP_SHLIB_SUFFIX);}$module = ‘my‘;$functions = get_extension_funcs($module);echo "Functions available in the test extension:$br\n";foreach($functions as $func) { echo $func."$br\n";}echo "$br\n";$function = ‘confirm_‘ . $module . ‘_compiled‘;if (extension_loaded($module)) { $str = $function($module);} else { $str = "Module $module is not compiled into PHP";}echo "$str\n";?>
my_test.php檔案內容:
<?php echo confirm_my_compiled(‘testmerlin‘);?>
編輯/etc/php5/cli/php.ini檔案,添加一行:
測試:
[email protected]:~/swinstall/php-5.6.4/ext/my$ php my_test.php Congratulations! You have successfully modified ext/my/config.m4. Module testmerlin is now compiled into PHP.
[email protected]:~/swinstall/php-5.6.4/ext/my$
學習使用簡單的php