hello readERs!
I try build my own template system... i'm doing fine but I found a sick problem I don't know what to do about... below short of my class
<?php
class temp
{
function replace($key, $value)
{
$str = 'hello world, my name is {NAME} and I like {LIKE}';
$this->result = str_replace($key, $value, $str);
}
function output()
{
print($this->result);
}
}
?>
so if I wrote this
$op = new temp();
$op->replace('{NAME}', 'adel');
$op->output();
will print "hello world, my name is adel and I like {LIKE}"
it's fine but if I wrote this
$op = new temp();
$op->replace('{NAME}', 'adel');
$op->replace('{LIKE}', 'php');
$op->output();
will print "hello world, my name is {NAME} and I like php",
while should print "hello world, my name is adel and I like php"
what the problem about? please help