NYCPHP Meetup

[nycphp-talk] About Human Readable Variable Names Moving Among PHP, HTML and MySQL

Anirudh Zala arzala at gmail.com
Wed Sep 27 06:57:28 EDT 2006


On Wed, 27 Sep 2006 16:04:27 +0530, Peter Sawczynec <ps at pswebcode.com>  
wrote:

> I'm always attempting a tight level of coordinated, human readable
> consistent naming for my data, i.e. I try to:
> a) use the same name such as "First Name" on my HTML form,
> b) use that variable name in my PHP script (i.e. $First_Name), and
> c) get the field name in tables in MySQL to match (again i.e. FirstName).
> When I work on projects that have HTML forms, email confirmations, MySQL
> storage,
> and Admin tools that view and sort the data, it is very handy when all  
> the
> data variable names
> are uniform and human readable at the same time. This way the onscreen  
> HTML
> display name for data variables can be the actual data name itself, and  
> then
> I can
> do less custom work when presenting data to all the users, in any
> permutation.
> My issues are about the spaces in data names. (To me, spaces is what  
> makes
> data names
> human readable.)
> In MySQL:
> I forget, you can use spaces, but should surround in tics, right. Like  
> so:
> 'First Name'.

Not recommended. using "_" instead of " " is as readable as " ".

> In PHP:
> Can't have spaces.
> In HTML forms:
> Can have spaces, but might cause problems.

Yeah, so "_" is better solution even here.

> So I'm just asking for an opinion, do you deal with spaces in variables?
> Never use spaces?

Nope, we never use spaces. Instead we use "_". Since PHP doesn't allow  
declaration of variables having space in it, It would be difficult to  
handle data (coming from Forms or stored into Database). I think "_" more  
or less denotes treating it as space.

> Is the problem of spaces just an old legacy, cross platform  
> Windows/Mac/Unix
> bad memory I have?
> Warmest regards,
> Peter Sawczynec
> Technology Director
> PSWebcode
> _Design & Interface
> _Ecommerce
> _Database Management
> 646.316.3678
> ps at pswebcode.com
> www.pswebcode.com <http://www.pswebcode.com/>
>

-----------------------------------------------
Anirudh Zala (Project Manager)
ASPL, http://www.aspl.in
arzala@@gmail.com
-----------------------------------------------



More information about the talk mailing list