Welcome Guest, Not a member yet? Register   Sign In
why using constants like LD , RD?
#1

[eluser]Unknown[/eluser]
i read in the CI guide here
http://ellislab.com/codeigniter/user-gui...#constants
that u should use
Code:
$str = str_replace(LD.'foo'.RD, 'bar', $str);
instead of
Code:
$str = str_replace('{foo}', 'bar', $str);
-
first: why should i do that , i.e: use the constants
-
second: where it is , i mean how could i use it in my controller
#2

[eluser]pickupman[/eluser]
I've been using CI for a couple of years, and have never used that code before. I think the intent on that particular instance is the curly braces. CI has parser class for converting strings inside curly braces into php variables. Since CI probably uses the constants to define the magic characters. A user code then configure to use another like square brackets instead. Some people may choose to write their own parser, or use another 3rd party library.

Your second question would be, you don't ned to unless you are trying to make your own template parser. There's a number a mature ones, so there shouldn't be any need for this.
#3

[eluser]Unknown[/eluser]
thanks , i forgeted the template parser
i don't use it , i use php code instead
-
i was confused because the example i refer to in the CI guide didn't refer to the template parser




Theme © iAndrew 2016 - Forum software by © MyBB