Archive - Feb 2007

Date

Do you know about ticks?

in

in PHP, there is a declare construct.

declare(directive){
    statements;
}

this allow the directive work inside the block
declare(directive);
This allow the directive work in the entire script.

There is only one directive, which is ticks.
What does ticks do? ticks will run a function after every few "tick"(statement).
suppose you want to run something after every line of code.

function cool(){
echo 'cool';
}
register_tick_function('cool');
declare(tick=1){
    echo 'haha';
echo 'haha';
echo 'haha';
echo 'haha';
echo 'haha';
}
 
output will be hahacoolhahacoolhahacoolhahacoolhahacool

What's the point of that function?
Because my first impression is: ZOMG some new crap I will never use! yeeah!
but soon i found it have a lot more use than just show off to people and piss them off. For instance:
Keep checking if a external stuff's status
Store how much memory used by each line
Anything you just don't want to be bothered to write once after each statement

Do you know about ticks?

in

in PHP, there is a declare construct.

declare(directive){
    statements;
}

this allow the directive work inside the block
declare(directive);
This allow the directive work in the entire script.

There is only one directive, which is ticks.
What does ticks do? ticks will run a function after every few "tick"(statement).

Have to get a new hosting

I have to get a new hosting. My site was down is because I don't have enough money for the hosting.
So I might have to use a very cheap $20 a year hosting...
So don't if the site is down again or something in this week you know I'm changing server and hosting.

Step by step showing you imarty 0.04's power!

Well, let me show you what I can do with my newest release of Imarty by doing one step at a time.
This is all the code you need

$imarty = new imarty('imagefile.xml');//get the XML file
$imarty->render();//render image
$imarty->output_image('gif');//out put gif image

First, let us create a image! Everything below is just changes of the imagefile.xml

<image w="20" h="20" cache="">
</image>

This defines the image's height and width, the cache system does not work yet but it will soon.

Finally, dynamically call classes and methods!

in

Introduction:
Dynamically call functions and methods can be used on making plugin systems where you send the same kind of data to a unknown function.

How to...
I suppose everyone knows how to dynamically call an function.
Suppose there are times you don't know what function you will call, you might want to express it into an array full of function names, and then use variable function system.

//This will be defined by a plugin writer
$rand_func[] = 'rand';
$rand_func[] = 'mt_rand';
$key = array_rand($rand_func);
Honey Pot that kill bots