[Fwd: Re: Can you have pragmas/literals in PHP?]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



er hit the wrong reply button...

-------- Original Message --------

zzapper wrote:
Hi,
I have set of php code lines that are often repeated . Functions are in this circumstance not
suitable.

why are functions not suitable? you are probably right but I'm interested to understand why. could you give us an example?

So my question is does PHP have what are in other languages sometimes called pragmas or literal.

I suppose they could be descibed as variables containing code.

you could tackle this in 2 ways:

1. use eval() to evaluate a string containing php code - define the strings in 1 place.
2. use include()/require() to include a file that contains the relevant code whenever you need
it.

I would use 2. unless you have a technical reason that dictates you must use 1.
eval() is comparitively slow and also has the potential to open up big security holes in
your application (if you want to know why then the http://phpsec.org site is probably a good place to
start reading about security and stuff).

oh and there is also the create_function() function which can be very handy in some circumstances.




-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux