PHP code example of uzulla / guardphp
1. Go to this page and download the library: Download uzulla/guardphp library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
uzulla / guardphp example snippets
\Uzulla\Guard as Guard;
chdir('/usr'); # カレントディレクトリを/tmpに変更
echo getcwd().PHP_EOL; # カレントディレクトリを表示
call_user_func(function(){
$g = new Guard(function(){ # Guardにコードを登録
chdir('/usr');
});
chdir('/'); # カレントディレクトリを/に変更
echo getcwd().PHP_EOL; # カレントディレクトリを表示
# ここでscopeがおわるので、上で登録したコードが実行される
});
echo getcwd().PHP_EOL; # カレントディレクトリを表示