#27823 [Com]: __FILE__ still not working properly in includes under Solaris

2004-04-05 Thread hurst at webteks dot com
 ID:   27823
 Comment by:   hurst at webteks dot com
 Reported By:  roy at pine dot nl
 Status:   Open
 Bug Type: Scripting Engine problem
 Operating System: Solaris 7
 PHP Version:  4.3.5
 New Comment:

This exact same problem occurs on a slightly different

Sun OS: SunOS matterhorn 5.8,

using both PHP4.3.5 and PHP4.2.0



--with-apache=../apache_1.3.29


Previous Comments:


[2004-04-01 04:03:28] roy at pine dot nl

Description:

The __FILE__ bug under Solaris (http://bugs.php.net/bug.php?id=13936)
is still there.

I tried the same script setup under FreeBSD and PHP 4.3.4 where it
works like intended.

Reproduce code:
---
--- test.php

?php

print __FILE__;

print p;

require(test2.php);

?



--- test2.php

?php

print __FILE__;

?



Expected result:

/home/whatever/www/test.php



/home/whatever/www/test2.php

Actual result:
--
/home/whatever/www/test.php



./test2.php





-- 
Edit this bug report at http://bugs.php.net/?id=27823edit=1


#24949 [Com]: Requesting a nicer way of setting undefined variables to a default value.

2003-08-18 Thread hurst at webteks dot com
 ID:   24949
 Comment by:   hurst at webteks dot com
 Reported By:  nickj-php at nickj dot org
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: Any
 PHP Version:  Irrelevant
 New Comment:

That there is no way to write a function to handle unset vars is also
something I have come across. 

One solution would be to use the @-symbol:

print noUnset(@$x, not set);

However, the @-symbol is not guaranteed to work, since
a user-defined error handler will ignore it.

Only isset(), unset(), and empty() can handle undefined variables
without implicitly declaring them.


Perhaps a new construct can be made available to handle
this common case.


default($var['not_a_key'],default_value) = default_value


It would work like the following function, but using the
caller environment (which could be from within another function):

function default($var,$default=)
{
return isset($var)?$var:$default;
}

Using  for the inherent default value makes sense
for web interfaces.


Previous Comments:


[2003-08-05 05:28:19] nickj-php at nickj dot org

Description:

Requesting a nicer way of setting undefined variables to a default
value.

It gets a bit repetitive and ugly having to use statements like:

$title   = isset($vals[title])  ? $vals[title]  :
;
$first   = isset($vals[first_name]) ? $vals[first_name] :
;
$surname = isset($vals[surname])? $vals[surname]:
;

This seems to be a recurrent requirement, so ideally there would be
some way of doing this, along the lines of :

function noUnset($val, $default=) {
return isset($val) ? $val : $default;
}

Unfortunately a user function such as the above cannot be defined to do
this, since the first argument passed to the function would be unset.

For example, this code will generate an error:

==

error_reporting (E_ALL);

function noUnset($val, $default=) {
return isset($val) ? $val : $default;
}

if (isset($x)) unset ($x);
// $x = 2; // works OK if this line is uncommented
print noUnset($x, not set);
// Above line generates an error as noUnset cannot be called with $x,
because it is not set - catch-22 !

==

This code generates an Undefined variable:  x error.

Ideally there would be slightly nicer way of setting defaults than a
bank is isset statements, that would work without generating an
error, even with all error reporting options turned on.






-- 
Edit this bug report at http://bugs.php.net/?id=24949edit=1