Re: [PHP] Session: I RTFM

2002-12-15 Thread michael kimsal
Marco Tabini wrote:

Single quotes are normal strings. Double quotes are strings in which
substitutions can take place. For example:



Double quotes also expand escape strings (e.g."\n") whereas single
quotes don't.


However, in a case like this:

--
What is the difference between:
$familyname = getvar("familyname");
and
$familyname = getvar('familyname');
--

There's no effective difference.

:)

Good magazine Marco - keep it up!

Michael Kimsal
http://www.phpappserver.com
734-480-9961


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Session: I RTFM

2002-12-15 Thread Marco Tabini
Single quotes are normal strings. Double quotes are strings in which
substitutions can take place. For example:



Double quotes also expand escape strings (e.g."\n") whereas single
quotes don't.

Cheers,


Marco
-- 

php|architect - The Magazine for PHP Professionals
The monthly magazine dedicated to the world of PHP programming

Check us out on the web at http://www.phparch.com!

--- Begin Message ---
Marco (or anyone)

What is the difference between:
$familyname = getvar("familyname");
and
$familyname = getvar('familyname');

What do single quotes do, as a general rule, that double cannot (he asks remembering 
something, but not sure what)?




Marco Tabini wrote:

> I haven't followed the rest of the thread, but how about using a
> function?
>
> function getvar ($varname)
> {
> if (isset ($_POST[$varname])
> {
> $_SESSION[$varname] = $_POST[$varname];
> return $_POST[$varname];
> }
> elseif (isset ($_SESSION[$varname]))
> return $_SESSION[$varname];
> }
>
> session_start();
>
> // You don't need session_register anymore
>
> $familyname = getvar('familyname');
>
> and so on--just one line per variable.
>
> Hope this helps.
>
> Cheers,
>
> Marco
> --
> 
> php|architect - The Magazine for PHP Professionals
> The monthly magazine dedicated to the world of PHP programming
>
> Check us out on the web at http://www.phparch.com!
>
>   
>---------------
>
> Subject: [PHP] Session: I RTFM
> Date: Sat, 14 Dec 2002 18:41:40 -0500
> From: John Taylor-Johnston <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Organization: FLSH, U-de-S
> To: [EMAIL PROTECTED]
>
> >Jason wrote:
> >RTFM again.
>
> Jason, again, I RTFM, but did not get it working.
> Otherwise I wouldn't have dared ask a question.
>
> >Sessions depends on a number of factors
> >including your version of PHP and the setting of register_globals.
>
> The FM manual says:
>
> "$_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended"
>
> So I am using "PHP Version 4.1.2" (and "4.2.3" on my localhost to test offline)
>
> Ok. I quit using $HTTP_POST_VARS["familyname"].
>
> With a little rethinking, I have this working, I hope.
>
> Now ... is there a cleaner way to assign my variable "familyname"?
>
> Pseudo code:
>
> if _post["familyname"] exists set session variable
>  (no sense in setting it until I post it)
> if _session["familyname"] exists, $familyname = $_SESSION["familyname"];
>
> I'll have about 30 variables. Going to be alot of lines. There must be an easier, 
>cleaner way?
>
>  #session_name("TestALS");
> session_start();
>
> if (isset($_POST["familyname"]))
> {
> session_register("familyname");
> $familyname = $_POST["familyname"];
> echo "Yay: \$familyname= $familyname";
> }
>
> if (isset($_SESSION["familyname"]))
> {
> $familyname = $_SESSION["familyname"];
> echo "yay session works, \$familyname= $familyname";
> }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--
John Taylor-Johnston
-
"If it's not open-source, it's Murphy's Law."

  ' ' '   Collège de Sherbrooke:
 ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
   - Université de Sherbrooke:
  http://compcanlit.ca/
  819-569-2064



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Session: I RTFM

2002-12-14 Thread Justin French
John,

PHP looks for "$vars or {$vars} to parse in the string" when double quotes
are used... whereas when single quotes are used, it won't parse/substitute
the vars.



So, when you're not using $vars, using single quotes will be marginally
faster... perhaps not important on small sites, but very important on big
ones, and a decent habbit to get into :)


Justin


on 15/12/02 12:30 PM, John Taylor-Johnston
([EMAIL PROTECTED]) wrote:

> Marco (or anyone)
> 
> What is the difference between:
> $familyname = getvar("familyname");
> and
> $familyname = getvar('familyname');
> 
> What do single quotes do, as a general rule, that double cannot (he asks
> remembering something, but not sure what)?
> 
> 
> 
> 
> Marco Tabini wrote:
> 
>> I haven't followed the rest of the thread, but how about using a
>> function?
>> 
>> function getvar ($varname)
>> {
>> if (isset ($_POST[$varname])
>> {
>> $_SESSION[$varname] = $_POST[$varname];
>> return $_POST[$varname];
>> }
>> elseif (isset ($_SESSION[$varname]))
>> return $_SESSION[$varname];
>> }
>> 
>> session_start();
>> 
>> // You don't need session_register anymore
>> 
>> $familyname = getvar('familyname');
>> 
>> and so on--just one line per variable.
>> 
>> Hope this helps.
>> 
>> Cheers,
>> 
>> Marco
>> --
>> 
>> php|architect - The Magazine for PHP Professionals
>> The monthly magazine dedicated to the world of PHP programming
>> 
>> Check us out on the web at http://www.phparch.com!
>> 
>> -
>> -
>> -
>> -
>> -
>> -
>> -
>> -------------
>> -
>> -
>> -
>> 
>> 
>> Subject: [PHP] Session: I RTFM
>> Date: Sat, 14 Dec 2002 18:41:40 -0500
>> From: John Taylor-Johnston <[EMAIL PROTECTED]>
>> Reply-To: [EMAIL PROTECTED]
>> Organization: FLSH, U-de-S
>> To: [EMAIL PROTECTED]
>> 
>>> Jason wrote:
>>> RTFM again.
>> 
>> Jason, again, I RTFM, but did not get it working.
>> Otherwise I wouldn't have dared ask a question.
>> 
>>> Sessions depends on a number of factors
>>> including your version of PHP and the setting of register_globals.
>> 
>> The FM manual says:
>> 
>> "$_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended"
>> 
>> So I am using "PHP Version 4.1.2" (and "4.2.3" on my localhost to test
>> offline)
>> 
>> Ok. I quit using $HTTP_POST_VARS["familyname"].
>> 
>> With a little rethinking, I have this working, I hope.
>> 
>> Now ... is there a cleaner way to assign my variable "familyname"?
>> 
>> Pseudo code:
>> 
>> if _post["familyname"] exists set session variable
>> (no sense in setting it until I post it)
>> if _session["familyname"] exists, $familyname = $_SESSION["familyname"];
>> 
>> I'll have about 30 variables. Going to be alot of lines. There must be an
>> easier, cleaner way?
>> 
>> > #session_name("TestALS");
>> session_start();
>> 
>> if (isset($_POST["familyname"]))
>> {
>> session_register("familyname");
>> $familyname = $_POST["familyname"];
>> echo "Yay: \$familyname= $familyname";
>> }
>> 
>> if (isset($_SESSION["familyname"]))
>> {
>> $familyname = $_SESSION["familyname"];
>> echo "yay session works, \$familyname= $familyname";
>> }
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> --
> John Taylor-Johnston
> -
> "If it's not open-source, it's Murphy's Law."
> 
> ' ' '   Collège de Sherbrooke:
> ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
> - Université de Sherbrooke:
> http://compcanlit.ca/
> 819-569-2064
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

Justin French

http://Indent.com.au
Web Development & 
Graphic Design



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Session: I RTFM

2002-12-14 Thread John Taylor-Johnston
Marco (or anyone)

What is the difference between:
$familyname = getvar("familyname");
and
$familyname = getvar('familyname');

What do single quotes do, as a general rule, that double cannot (he asks remembering 
something, but not sure what)?




Marco Tabini wrote:

> I haven't followed the rest of the thread, but how about using a
> function?
>
> function getvar ($varname)
> {
> if (isset ($_POST[$varname])
> {
> $_SESSION[$varname] = $_POST[$varname];
> return $_POST[$varname];
> }
> elseif (isset ($_SESSION[$varname]))
> return $_SESSION[$varname];
> }
>
> session_start();
>
> // You don't need session_register anymore
>
> $familyname = getvar('familyname');
>
> and so on--just one line per variable.
>
> Hope this helps.
>
> Cheers,
>
> Marco
> --
> 
> php|architect - The Magazine for PHP Professionals
> The monthly magazine dedicated to the world of PHP programming
>
> Check us out on the web at http://www.phparch.com!
>
>   
>---------------
>
> Subject: [PHP] Session: I RTFM
> Date: Sat, 14 Dec 2002 18:41:40 -0500
> From: John Taylor-Johnston <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Organization: FLSH, U-de-S
> To: [EMAIL PROTECTED]
>
> >Jason wrote:
> >RTFM again.
>
> Jason, again, I RTFM, but did not get it working.
> Otherwise I wouldn't have dared ask a question.
>
> >Sessions depends on a number of factors
> >including your version of PHP and the setting of register_globals.
>
> The FM manual says:
>
> "$_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended"
>
> So I am using "PHP Version 4.1.2" (and "4.2.3" on my localhost to test offline)
>
> Ok. I quit using $HTTP_POST_VARS["familyname"].
>
> With a little rethinking, I have this working, I hope.
>
> Now ... is there a cleaner way to assign my variable "familyname"?
>
> Pseudo code:
>
> if _post["familyname"] exists set session variable
>  (no sense in setting it until I post it)
> if _session["familyname"] exists, $familyname = $_SESSION["familyname"];
>
> I'll have about 30 variables. Going to be alot of lines. There must be an easier, 
>cleaner way?
>
>  #session_name("TestALS");
> session_start();
>
> if (isset($_POST["familyname"]))
> {
> session_register("familyname");
> $familyname = $_POST["familyname"];
> echo "Yay: \$familyname= $familyname";
> }
>
> if (isset($_SESSION["familyname"]))
> {
> $familyname = $_SESSION["familyname"];
> echo "yay session works, \$familyname= $familyname";
> }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--
John Taylor-Johnston
-
"If it's not open-source, it's Murphy's Law."

  ' ' '   Collège de Sherbrooke:
 ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
   - Université de Sherbrooke:
  http://compcanlit.ca/
  819-569-2064



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Session: I RTFM

2002-12-14 Thread Marco Tabini
I haven't followed the rest of the thread, but how about using a
function?

function getvar ($varname)
{
if (isset ($_POST[$varname])
{
$_SESSION[$varname] = $_POST[$varname];
return $_POST[$varname];
}
elseif (isset ($_SESSION[$varname]))
return $_SESSION[$varname];
}

session_start();

// You don't need session_register anymore

$familyname = getvar('familyname');


and so on--just one line per variable.

Hope this helps.

Cheers,


Marco
-- 

php|architect - The Magazine for PHP Professionals
The monthly magazine dedicated to the world of PHP programming

Check us out on the web at http://www.phparch.com!

--- Begin Message ---
>Jason wrote:
>RTFM again.

Jason, again, I RTFM, but did not get it working.
Otherwise I wouldn't have dared ask a question.

>Sessions depends on a number of factors
>including your version of PHP and the setting of register_globals.

The FM manual says:

"$_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended"

So I am using "PHP Version 4.1.2" (and "4.2.3" on my localhost to test offline)

Ok. I quit using $HTTP_POST_VARS["familyname"].

With a little rethinking, I have this working, I hope.

Now ... is there a cleaner way to assign my variable "familyname"?

Pseudo code:

if _post["familyname"] exists set session variable
 (no sense in setting it until I post it)
if _session["familyname"] exists, $familyname = $_SESSION["familyname"];

I'll have about 30 variables. Going to be alot of lines. There must be an easier, 
cleaner way?


";
}

if (isset($_SESSION["familyname"]))
{
$familyname = $_SESSION["familyname"];
echo "yay session works, \$familyname= $familyname";
}




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Session: I RTFM

2002-12-14 Thread John Taylor-Johnston
>Jason wrote:
>RTFM again.

Jason, again, I RTFM, but did not get it working.
Otherwise I wouldn't have dared ask a question.

>Sessions depends on a number of factors
>including your version of PHP and the setting of register_globals.

The FM manual says:

"$_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended"

So I am using "PHP Version 4.1.2" (and "4.2.3" on my localhost to test offline)

Ok. I quit using $HTTP_POST_VARS["familyname"].

With a little rethinking, I have this working, I hope.

Now ... is there a cleaner way to assign my variable "familyname"?

Pseudo code:

if _post["familyname"] exists set session variable
 (no sense in setting it until I post it)
if _session["familyname"] exists, $familyname = $_SESSION["familyname"];

I'll have about 30 variables. Going to be alot of lines. There must be an easier, 
cleaner way?


";
}

if (isset($_SESSION["familyname"]))
{
$familyname = $_SESSION["familyname"];
echo "yay session works, \$familyname= $familyname";
}




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php