Re: PHP and #if

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

 



Eric Gorr wrote:
> Unfortunately, such things cannot be used to wrap functions.
> 
> 
> 
> On Mar 14, 2008, at 2:38 PM, Dave Goodchild wrote:
> 
>> in php you have a number of constructs that can be used to execute
>> code (or not) based on certain conditions ie is_defined(). Not sure if
>> the comparison with C holds true as C is compiled and PHP is interpreted.
>>
>> On Fri, Mar 14, 2008 at 6:34 PM, Eric Gorr <mailist@xxxxxxxxxxxx> wrote:
>> If you are talking about simply commenting code out, yes, I am aware
>> of this...however, the #if technique is far more capable in certain
>> situations.
>>
>> There are reasons why C, etc. has included the ability to comment out
>> lines of code and also provide #if's.
>>
>> But based on your reply, I have to assume that PHP does not current
>> provide such a technique...as I suspected.
>>
>>
>> On Mar 14, 2008, at 2:22 PM, Børge Holen wrote:
>>
>> > On Friday 14 March 2008 19:19:30 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.
>> >
>> > # Notin' here
>> > // here neither
>> > */
>> > Nor there
>> > /*
>> >
>> > --
>> > ---
>> > Børge Holen
>> > http://www.arivene.net
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>>
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 
Surrounding a bit of code/function in an if statement in PHP does the
same thing as the #if in C because PHP is interpreted.

In C, if the #if is true then the compiler compiles the code and when
you execute the binary the code is executed, if the #if is false then
the code is not compiled so it can't execute because it isn't there.

In PHP, if you execute the script and the if is true then the code
executes, if the if is false then the code doesn't execute.

Same same...

-Shawn

-- 
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