Reply to Re: Newbie question(s) #2: Creating 'output' with form-collected variables

Your name:

Reply:


Posted by Toby A Inkster on 02/20/07 11:54

murrayatuptowngallery wrote:

> I think PHP is more flexible with variables...whether or not it is a
> good practice, they apparently do not need to be explicitly defined by
> type (they are interpreted by content?),

Mostly by *context* rather than *content*. For example:

<?php
// a single character string
$var = "4";

// Let's do regular-expression matching. $var is expected
// to be a string, so PHP treats it as a string.
$match_found = preg_match('/[0-9]/', $var);

// Let's do some maths. It doesn't make sense to do
// subtraction on strings, so PHP treats $var as a number.
$difference = $var - 1;

// $match_found is TRUE.
// $difference is 3.
?>

> but are they automatically assumed to be global?

What you're describing appears to be sessions, which are well supported by
PHP. Globals are something different -- they only exist within the scope
of an execution cycle (i.e., normally, a single page request).

I won't bother giving an example of how to use sessions, as Kimmo already
has.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация