Discussion: email issue
Afficher un message
Vieux 16/03/2008, 10h51   #17
Hector Santos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP and #if

On Mar 14, 2:19 pm, mail...@ericgorr.net (Eric Gorr) wrote:
> In C, etc. one can place #if's around code to determine whether or not
> the compiler should pay any attention to the code.
>
> Is there a similar technique for PHP?
>
> I've not seen anything like this before and a brief search hasn't
> turned up anything either...just thought I would ask to make sure.


This is part of the C compiler pragmas. But I am relatively new to
the PHP language, but I don't believe PHP supports pragmas.

I use pragma all the time in my C/C++ code. When testing or exploring
logic, I just surround code with if (true|false) {} wrappers and might
use defines as well, example:

define("USE_SPECIAL_CODE", false);

....
if (USE_SPECIAL_CODE) {
} else {
}

or something like:

if (0)
{
original logic
}
some new version of your logic

Yes, not the same thing. But you if you are distributing this stuff,
unless the logic is an useable and optional part of the application,
you don't want to include these snippets in your distribution anyway.
After all, PHP is not distributed as compiled code ... not yet
atleast. :-)
  Réponse avec citation
 
Page generated in 0,04603 seconds with 9 queries