TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 195,994
  • Total Topics: 21,325
  • Online today: 292
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 125
  • Total: 125

Undefined constants and variables

Started by JPDeni, July 24, 2006, 01:59:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Thurnok

Quote from: JPDeni on July 25, 2006, 05:33:10 PM
It would make things easier if it just wouldn't work unless you put the quotes in.

JPDeni, for the sake of your curiosity:
Unquoted strings in php are considered constants.  The reason it actually works is because the php parser takes any unquoted literal index that does not match a known symbol (or constant) and turns it into a string.  If for example however, you had a constant in your code  somewhere called end_date it would have obviously not worked in addition to providing an error.  So though you can actually get away with unquoted literal indexes, you may actually break your code in the future if say, you upgrade php on your server and the new version of php contains a new symbol that matches a literal index you have used.

You will mostly find this type of convention used in older scripts where the author(s) were shortcutting the process for expanding or not expanding array values in print() or echo'' strings.  It is definately not a good programming practice by today's standards however, so should be avoided.
Thurnok
The one, the only!

JPDeni

Thanks so much for the info. I will definitely change my lazy ways.  :laugh:

This website is proudly hosted on Crocweb Cloud Website Hosting.