$begin = memory_get_usage();
$foo = &new Foo();
$second = memory_get_usage();
echo "allocation time: ".( $second-$begin) . "
";
Personal notes ~
2008年7月22日 星期二
2008年7月21日 星期一
CLI run CI
from
http://codeigniter.com/forums/viewthread/78610/
Thanks for your help but i did a file who modify routes.php with sed (unix-command) because the OS is FreeBSD and then this file execute the index.php with the good route.
exec("sed -i.bak 's/\".*\";/\"controllers_name\";/1' ./system/application/config/routes.php",$sortie);
$argv=$_SERVER['argv'];
$argc=$_SERVER['argc'];
$str='';
for($i=1;$i<$argc;$i++)
$str=$str.' '.$argv[$i];
passthru("php index.php".$str,$s);
exit($s);
http://codeigniter.com/forums/viewthread/78610/
Thanks for your help but i did a file who modify routes.php with sed (unix-command) because the OS is FreeBSD and then this file execute the index.php with the good route.
exec("sed -i.bak 's/\".*\";/\"controllers_name\";/1' ./system/application/config/routes.php",$sortie);
$argv=$_SERVER['argv'];
$argc=$_SERVER['argc'];
$str='';
for($i=1;$i<$argc;$i++)
$str=$str.' '.$argv[$i];
passthru("php index.php".$str,$s);
exit($s);
2008年7月8日 星期二
Variable scope
http://tw2.php.net/global
Using static variables
Another important feature of variable scoping is the static variable. A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope. Consider the following example:
Static variables also provide one way to deal with recursive functions. A recursive function is one which calls itself. Care must be taken when writing a recursive function because it is possible to make it recurse indefinitely. You must make sure you have an adequate way of terminating the recursion. The following simple function recursively counts to 10, using the static variable $count to know when to stop:
Using static variables
Another important feature of variable scoping is the static variable. A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope. Consider the following example:
function Test()
{
$a = 0;
echo $a;
$a++;
}
?>
Static variables also provide one way to deal with recursive functions. A recursive function is one which calls itself. Care must be taken when writing a recursive function because it is possible to make it recurse indefinitely. You must make sure you have an adequate way of terminating the recursion. The following simple function recursively counts to 10, using the static variable $count to know when to stop:
function Test()
{
static $count = 0;
$count++;
echo $count;
if ($count < 10) {
Test();
}
$count--;
}
?>
-------------------------------------------------------------------------
class Foo
{
public static $my_static = 'foo';
public function staticValue() {
return self::$my_static;
}
}
class Bar extends Foo
{
public function fooStatic() {
return parent::$my_static;
}
}
print Foo::$my_static . "\n";
$foo = new Foo();
print $foo->staticValue() . "\n";
print $foo->my_static . "\n"; // Undefined "Property" my_static
print $foo::$my_static . "\n";
$classname = 'Foo';
print $classname::$my_static . "\n"; // As of PHP 5.3.0
print Bar::$my_static . "\n";
$bar = new Bar();
print $bar->fooStatic() . "\n";
訂閱:
文章 (Atom)
追蹤網誌清單
IT Info
Reference
標籤
- 代討論
- 防盜
- 常規表示式(regular expression)
- 進度
- 電子地圖
- 網站搬家程式
- Ajax Library
- Application of Perl
- C#
- CakePHP
- Coding Convention
- CSS
- Data injection
- DBI
- Debug
- Diff Browser
- Effect : Slideshow
- Engineering - Desing Pattern
- framework
- Framework - CodeIgniter
- Functions
- Imgick
- jquery
- JS Framework
- JS Library
- JS Object : Statement
- Linux
- Mapping Other Language
- Need to Turnning
- NetBeans
- OOAD-MVC
- open source suit software
- Performance
- Perl Installation
- PHP Class
- PHP rpc Java
- PHP to PERL
- Presentation
- RIA
- Serculity
- Service
- SQL injection
- Tips
- Tools
- Variable
- Versus
- WCF
- WebSite Thumbnail
- XML
- ZK Ajax