|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
This is a really basic question for all you people out there who know
PHP. This is not a problem but just something I'm confused about. I was reading the article below and wondered why are normal constants set with quotes around them, while "class constants" (those little things I learned yesterday from the article) don't have to have quotes around the constants when you define them? It seems really weird to me why PHP would do it this way?? Constants: http://www.talkphp.com/showthread.php?t=1151 Could someome please explain to me the reasons why there are 2 ways to define them - one via a function, and one via, what is it? A language construct? I don't know. The latter having no quotes around to define!! Really weird. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
<adam.timberlake@gmail.com> wrote in message news:f2e552b9-4d03-4a2c-8137-acf51a7e3447@l1g2000hsa.googlegroups.com... > This is a really basic question for all you people out there who know > PHP. This is not a problem but just something I'm confused about. I > was reading the article below and wondered why are normal constants > set with quotes around them, while "class constants" (those little > things I learned yesterday from the article) don't have to have quotes > around the constants when you define them? It seems really weird to me > why PHP would do it this way?? > > Constants: http://www.talkphp.com/showthread.php?t=1151 > > Could someome please explain to me the reasons why there are 2 ways to > define them - one via a function, and one via, what is it? A language > construct? I don't know. The latter having no quotes around to > define!! Really weird. not weird at all. in php < 5, there's only one way to define a constant: define('A_CONSTANT', 666); in php 5+, define() is kept not only for backward compatability but for other reasons as well. the difference is, with newer versions of php, we've picked up a new language construct, const. so now, you can define a constant just at you did class vars in php (all versions)... class foo { const A_CONSTANT = 666; var $someVar = 777; } it's simply a matter of a language construct change. |
|
![]() |
| Outils de la discussion | |
|
|