php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54313 What I thought before...
Submitted: 2011-03-19 11:22 UTC Modified: 2011-03-23 16:43 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: oop at dr dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oop at dr dot com
New email:
PHP Version: OS:

 

 [2011-03-19 11:22 UTC] oop at dr dot com
Description:
------------
---
From manual page: http://www.php.net/function.define#Examples
---

<?php
define("CONSTANT", "Hello world.",false);
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and issues a notice.

define("GREETING", "Hello you.", true);
echo GREETING; // outputs "Hello you."
echo Greeting; // outputs "Hello you."

?>

If the case_sensitive is true, why GREETING and Greeting output the same value (Hello you)? Then I put ,false just after "Hello world.", why CONSTANT and Constant output the different values? Plus the echo Constant; does not issue a notice.

Test script:
---------------
<?php
define("CONSTANT", "Hello world.",false);
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and issues a notice.

define("GREETING", "Hello you.", true);
echo GREETING; // outputs "Hello you."
echo Greeting; // outputs "Hello you."

?>

If the case_sensitive is true, why GREETING and Greeting output the same value (Hello you)? Then I put ,false just after "Hello world.", why CONSTANT and Constant output the different values? Plus the echo Constant; does not issue a notice.

Expected result:
----------------
<?php
define("CONSTANT", "Hello world.",false);
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Hello world."

define("GREETING", "Hello you.", true);
echo GREETING; // outputs "Hello you."
echo Greeting; // outputs Greeting

?>

Actual result:
--------------
<?php
define("CONSTANT", "Hello world.",false);
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and NEVER issues a notice.

define("GREETING", "Hello you.", true);
echo GREETING; // outputs "Hello you."
echo Greeting; // outputs "Hello you."

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-19 11:53 UTC] scottmac@php.net
-Status: Open +Status: Bogus
 [2011-03-19 11:53 UTC] scottmac@php.net
the flag is case insensitive, not case sensitive
 [2011-03-22 06:04 UTC] oop at dr dot com
-Summary: Logical Flaw +Summary: Illogicalness
 [2011-03-22 06:04 UTC] oop at dr dot com
Changed Summary
 [2011-03-22 06:20 UTC] oop at dr dot com
-Summary: Illogicalness +Summary: What I thought before...
 [2011-03-22 06:20 UTC] oop at dr dot com
Changed Summary
 [2011-03-22 06:33 UTC] oop at dr dot com
scottmac... you are right. shame...
 [2011-03-22 06:39 UTC] oop at dr dot com
This is counterintuitive. case_sensitive = true is definitely more straightforward than case_insensitive = false.
 [2011-03-22 06:45 UTC] scottmac@php.net
It's been this way for more than 10 years.

Also as a default, case sensitive makes more sense.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 03:01:35 2025 UTC