Case-sensitive include_once()

General discussion on Zend Core for IBM System i
Post Reply
aaron-s-hawley
Posts: 46
Joined: Thu Mar 11, 2010 4:43 pm
Location: Colchester, VT
Contact:

Case-sensitive include_once()

Post by aaron-s-hawley » Thu Mar 11, 2010 10:09 pm

For IFS on the i5/OS, system resources are case-insensitive. Shouldn't PHP's include_once() and require_once() work so that a file isn't included if the case is different?

Example:
--------

Code: Select all

<?php
if (isset($is_included) && $is_included == true) {
  print "Included!\n";
} else {
  $is_included = true;
  include_once __FILE__;
  include_once strtoupper(__FILE__);
}
?>
Expected result:
----------------

[The page should be blank.]

Actual result:
--------------

"Included!"

Strangely enough, there is a check for this kind of thing in PHP's test suite, but I think it only is run on W32 machines.

http://svn.php.net/viewvc/php/php-src/b ... iew=markup

I don't have the ability to test Zend Server since our environment is V5R3 at the moment. Has it been addresses in newer releases?

Thanks for Zend Core for the i.

chris_hird
Posts: 171
Joined: Fri Apr 10, 2009 12:41 am
Location: Toronto
Contact:

Re: Case-sensitive include_once()

Post by chris_hird » Thu Apr 08, 2010 12:58 am

I think your code is the reason for the error?

You are testing a variable $is_included without it being defined, then you are checking if that same variable is true? If you look in the Studio at your code you will see a warning which states the variable $is_Included has not been set!

Not sure on how the interpreter works but it is always bad programming to see if an undefined variable has been set or if it is true?

Just so you know ZendServer gives the same output with your code. I created the following and it works as expected. Not sure what you are trying to achieve with your code so its hard to give any better answer. This has nothing to do with case sensitive characters though?

Code: Select all

<?php
$is_included = false;
if (isset($is_included) && $is_included == true) {
  print "Included!\n";
} else {
  $is_included = true;
  include_once __FILE__;
  include_once strtoupper(__FILE__);
}
?>

Chris...
Shield Advanced Solutions Ltd
Home of JobQGenie and the Receiver Apply Program
http://www.shield.on.ca/Blog

aaron-s-hawley
Posts: 46
Joined: Thu Mar 11, 2010 4:43 pm
Location: Colchester, VT
Contact:

Re: Case-sensitive include_once()

Post by aaron-s-hawley » Thu Apr 08, 2010 12:58 pm

Thanks for testing my script in Zend Server. I'm not surprised this bug hasn't been fixed.

I probably should have mentioned that the file needs to have a name with lowercase letters, that way strtoupper() converts it to an uppercase version. The warning from Zend Studio is comical. Thanks for sharing that. Sorry my code is confusing. It's a bit terse, I know.

Thanks again.

Post Reply