Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread M. Sokolewicz

Aside from the 20 suggestions you've already got, let me add this one:
elseif( ($page != one) or ($page != two) or ($page != NULL) ) {

 Echo htmlheadtitleUndefined!/title/headbodypage isn't
 defined correctly!/body/html;
 }

is useless code. Why?
$page = null; never happens (you made sure of that further up the page).
$page = one; never happens (you already pulled that one out earlier).
$page = two; never happens (you already pulled that one out earlier).

So... if *any* of those returns true you show an error... may I suggest 
just changing it to an else instead? a lot more logical(!).
Besides that, were you to move this to its own if() you'd notice it 
would always display because if the page is one it *can not* be two 
or null, and will thus be displayed. Which means that you'd have an 
error which would always display...


oh well, ignore my rant and first make sure to follow the suggestions 
provided by others


- tul
Wolf wrote:

What is it doing, or not doing?

Try changing the ? to ?php and see if that works.

Robert

Erik Johnson wrote:


I do not know why this isn't working, but it would be very helpful if
someone looked over it.

?
$defaultpage = http://lom.game-host.org/uploads/erik/;;

If($page == NULL) {
   $page = one;
}

if($page == one) {
   Echo htmlheadtitlePage One/title/headbodyIt works!!bra
href=\ . $defaultpage . index.php?page=two\Nice.../a/body/html;
}

elseif($page == two) {
   Echo htmlheadtitlePage Two/title/headbodyThis is page  .
$page .  -- a href=\ . $defaultpage . index.php
?page=\;D/a/body/html;
}

elseif( ($page != one) or ($page != two) or ($page != NULL) ) {
   Echo htmlheadtitleUndefined!/title/headbodypage isn't
defined correctly!/body/html;
}

if($page == ) {
   Echo brbrbrbrbrbrbrbra href= . $defaultpage . Main
Page../a;
}
?

Thank you,

Erik Johnson



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



Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Zareef Ahmed
Hi Johnson,

what is not working in this code?
what is the problem? It will always execute the first part of if condition,
i.e.
It will print

htmlheadtitlePage One/title/headbodyIt works!!bra
href=http://lom.game-host.org/uploads/erik/index.php?page=two;Nice.../a
/body/html

What you are expecting from this script?


One recommendation, it is better to use isset  function to check if variable
has been set or not.

Zareef Ahmed

- Original Message - 
From: Erik Johnson [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Saturday, December 17, 2005 11:05 PM
Subject: [PHP] Someone please help me with this PHP script.


I do not know why this isn't working, but it would be very helpful if
someone looked over it.

?
$defaultpage = http://lom.game-host.org/uploads/erik/;;

If($page == NULL) {
$page = one;
}

if($page == one) {
Echo htmlheadtitlePage One/title/headbodyIt works!!bra
href=\ . $defaultpage . index.php?page=two\Nice.../a/body/html;
}

elseif($page == two) {
Echo htmlheadtitlePage Two/title/headbodyThis is page  .
$page .  -- a href=\ . $defaultpage . index.php
?page=\;D/a/body/html;
}

elseif( ($page != one) or ($page != two) or ($page != NULL) ) {
Echo htmlheadtitleUndefined!/title/headbodypage isn't
defined correctly!/body/html;
}

if($page == ) {
Echo brbrbrbrbrbrbrbra href= . $defaultpage . Main
Page../a;
}
?

Thank you,

Erik Johnson




PHP Expert Consultancy in Development  http://www.indiaphp.com
Yahoo! : consultant_php MSN : [EMAIL PROTECTED]

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



Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Erik Johnson
Well. Here's an example of the page --
http://lom.game-host.org/uploads/erik/

It is just loading the second page, no matter what. I haven't added the
isset thing yet, but I'll try it. BTW: I'm only 14, so I have yet to use an
older version, and upgrade to a newer PHP.  ;-)

Thanks,

Erik Johnson


On 12/18/05, Zareef Ahmed [EMAIL PROTECTED] wrote:

 Hi Johnson,

 what is not working in this code?
 what is the problem? It will always execute the first part of if
 condition,
 i.e.
 It will print

 htmlheadtitlePage One/title/headbodyIt works!!bra
 href=http://lom.game-host.org/uploads/erik/index.php?page=two;
 Nice.../a
 /body/html

 What you are expecting from this script?


 One recommendation, it is better to use isset  function to check if
 variable
 has been set or not.

 Zareef Ahmed

 - Original Message -
 From: Erik Johnson [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Saturday, December 17, 2005 11:05 PM
 Subject: [PHP] Someone please help me with this PHP script.


 I do not know why this isn't working, but it would be very helpful if
 someone looked over it.

 ?
 $defaultpage = http://lom.game-host.org/uploads/erik/;;

 If($page == NULL) {
$page = one;
 }

 if($page == one) {
Echo htmlheadtitlePage One/title/headbodyIt works!!bra
 href=\ . $defaultpage . index.php
 ?page=two\Nice.../a/body/html;
 }

 elseif($page == two) {
Echo htmlheadtitlePage Two/title/headbodyThis is page  .
 $page .  -- a href=\ . $defaultpage . index.php
 ?page=\;D/a/body/html;
 }

 elseif( ($page != one) or ($page != two) or ($page != NULL) ) {
Echo htmlheadtitleUndefined!/title/headbodypage isn't
 defined correctly!/body/html;
 }

 if($page == ) {
Echo brbrbrbrbrbrbrbra href= . $defaultpage . Main
 Page../a;
 }
 ?

 Thank you,

 Erik Johnson



 
 PHP Expert Consultancy in Development  http://www.indiaphp.com
 Yahoo! : consultant_php MSN : [EMAIL PROTECTED]





Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Erik Johnson
I was wondering.. how exactly does the isset function work?  I saw that
Robert Cummings wrote:

$page = isset( $_GET['page'] ) ? $_GET['page'] : null;

What exactly does that mean?


Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Łukasz Hejnak

Zareef Ahmed napisał(a):

Hi,

Hi

what is not working in this code?

That's how I see it
?
$defaultpage = http://lom.game-host.org/uploads/erik/;;
// yes the isset is ok here
If(!isset($page)) {
$page = one;
}


if($page == one) {
// as far as I know echo is all low case written but maybe it's not a 
must in all instalations
echo htmlheadtitlePage One/title/headbodyIt 
works!!bra href=\ . $defaultpage . 
index.php?page=two\Nice.../a/body/html;

}

// else space_here if, not elseif !
else if($page == two) {
echo htmlheadtitlePage Two/title/headbodyThis is page 
.$page. -- a 
href=\.$defaultpage.index.php?page=\;D/a/body/html;

}

//  instead of || (and instead of or) here to have the opposite!
else if( ($page != one)  ($page != two)  ($page != NULL) ) {
echo htmlheadtitleUndefined!/title/headbodypage isn't 
defined correctly!/body/html;

}

if($page == ) {
Echo brbrbrbrbrbrbrbra href=.$defaultpage.Main 
Page../a;

}
?

Thank you,

You're welcome :)

--
Best wishes
Łukasz 'Szift' Hejnak

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



Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Zareef Ahmed

- Original Message - 
From: Erik Johnson [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Sunday, December 18, 2005 10:41 AM
Subject: Re: [PHP] Someone please help me with this PHP script.


I was wondering.. how exactly does the isset function work?  I saw that
Robert Cummings wrote:

$page = isset( $_GET['page'] ) ? $_GET['page'] : null;

What exactly does that mean?


isset function checks if a given variable is set or not, in above line of
code you are seeing its use with operator (?).

What it will do:
It will check if there is any variable with named $_GET['page'], it is true
then it will assign the value of $_GET['page'] to $page variable, otherwise
it will be set to null value.

You are 14?? Welcome to the wonderfull world of PHP programming.

Zareef Ahmed





PHP Expert Consultancy in Development  http://www.indiaphp.com
Yahoo! : consultant_php MSN : [EMAIL PROTECTED]

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



RE: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Oli Howson
The ? And : are a shortcut for ifelse, that could also be written

If (isset($_GET['page'])
{
 $page = $_GET['page'];
}
else
{
 $page = null;
}

The shortcut is a lot quicker to write (if you understand it) but not as
readable.

isset just returns true if a variable has been set, false if not :)

hth

-Original Message-
From: Erik Johnson [mailto:[EMAIL PROTECTED] 
Sent: 18 December 2005 15:42
To: php-general@lists.php.net
Subject: Re: [PHP] Someone please help me with this PHP script.

I was wondering.. how exactly does the isset function work?  I saw that
Robert Cummings wrote:

$page = isset( $_GET['page'] ) ? $_GET['page'] : null;

What exactly does that mean?

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



Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Erik Johnson
Thank you very much.  My dad is in college, but I have been teaching myself
HTML, Java, VB6, and PHP.  I've been learning to do graphical artwork with
Adobe Illustrator, and Photoshop.  I actually started programming before my
dad was in school, and I got him started I guess!  Anyway; I've learnt a
lot, and I hope to learn more, as I'm trying to make an online MMORPG /
ORPG.

Back on topic:  I looked IsSet() on PHP.net, but it didn't give that fluent
of an explanation.  Thanks!  I'll be sure to try it out.  If someone tries
my php script, and wants to make any changes, please just upload it to
ftp://lom.game-host.org/ .

Thanks again,

Erik Johnson


Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Erik Johnson
I still can't seem to get it to work.  If you want to see my phpinfo(), then
go to http://lom.game-host.org/uploads/erik/info.php .

I'll keep trying, and hope for the best!  It may be my php.ini file, but I
have no clue.


Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Zareef Ahmed

- Original Message - 
From: M. Sokolewicz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: PHP LIST php-general@lists.php.net
Sent: Sunday, December 18, 2005 4:34 AM
Subject: Re: [PHP] Someone please help me with this PHP script.


 Aside from the 20 suggestions you've already got, let me add this one:
 elseif( ($page != one) or ($page != two) or ($page != NULL) ) {

   Echo htmlheadtitleUndefined!/title/headbodypage isn't
   defined correctly!/body/html;
   }

 is useless code. Why?
 $page = null; never happens (you made sure of that further up the page).
 $page = one; never happens (you already pulled that one out earlier).
 $page = two; never happens (you already pulled that one out earlier).


Johnson, make a note of it.

you can also read about switch statement.

Zareef Ahmed

 So... if *any* of those returns true you show an error... may I suggest
 just changing it to an else instead? a lot more logical(!).
 Besides that, were you to move this to its own if() you'd notice it
 would always display because if the page is one it *can not* be two
 or null, and will thus be displayed. Which means that you'd have an
 error which would always display...

 oh well, ignore my rant and first make sure to follow the suggestions
 provided by others

 - tul
 Wolf wrote:
  What is it doing, or not doing?
 
  Try changing the ? to ?php and see if that works.
 
  Robert
 
  Erik Johnson wrote:
 
 I do not know why this isn't working, but it would be very helpful if
 someone looked over it.
 
 ?
 $defaultpage = http://lom.game-host.org/uploads/erik/;;
 
 If($page == NULL) {
 $page = one;
 }
 
 if($page == one) {
 Echo htmlheadtitlePage One/title/headbodyIt
works!!bra
 href=\ . $defaultpage .
index.php?page=two\Nice.../a/body/html;
 }
 
 elseif($page == two) {
 Echo htmlheadtitlePage Two/title/headbodyThis is page 
.
 $page .  -- a href=\ . $defaultpage . index.php
 ?page=\;D/a/body/html;
 }
 
 elseif( ($page != one) or ($page != two) or ($page != NULL) ) {
 Echo htmlheadtitleUndefined!/title/headbodypage isn't
 defined correctly!/body/html;
 }
 
 if($page == ) {
 Echo brbrbrbrbrbrbrbra href= . $defaultpage .
Main
 Page../a;
 }
 ?
 
 Thank you,
 
 Erik Johnson
 

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




PHP Expert Consultancy in Development  http://www.indiaphp.com
Yahoo! : consultant_php MSN : [EMAIL PROTECTED]




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



Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Erik Johnson
Okay.. I was just wondering; What's the difference between = and ==? Would
it matter if I changed them?  It seems as though if I put = instead of the
=='s, it comes up ONLY page two no matter what $page equals, and if it's ='s
instead of =='s, then it comes up with only page one no matter what $page
equals.

On 12/18/05, Zareef Ahmed [EMAIL PROTECTED] wrote:


 - Original Message -
 From: M. Sokolewicz [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Cc: PHP LIST php-general@lists.php.net
 Sent: Sunday, December 18, 2005 4:34 AM
 Subject: Re: [PHP] Someone please help me with this PHP script.


  Aside from the 20 suggestions you've already got, let me add this one:
  elseif( ($page != one) or ($page != two) or ($page != NULL) ) {
 
Echo htmlheadtitleUndefined!/title/headbodypage isn't
defined correctly!/body/html;
}
 
  is useless code. Why?
  $page = null; never happens (you made sure of that further up the page).
  $page = one; never happens (you already pulled that one out earlier).
  $page = two; never happens (you already pulled that one out earlier).
 

 Johnson, make a note of it.

 you can also read about switch statement.

 Zareef Ahmed

  So... if *any* of those returns true you show an error... may I suggest
  just changing it to an else instead? a lot more logical(!).
  Besides that, were you to move this to its own if() you'd notice it
  would always display because if the page is one it *can not* be two
  or null, and will thus be displayed. Which means that you'd have an
  error which would always display...
 
  oh well, ignore my rant and first make sure to follow the suggestions
  provided by others
 
  - tul
  Wolf wrote:
   What is it doing, or not doing?
  
   Try changing the ? to ?php and see if that works.
  
   Robert
  
   Erik Johnson wrote:
  
  I do not know why this isn't working, but it would be very helpful if
  someone looked over it.
  
  ?
  $defaultpage = http://lom.game-host.org/uploads/erik/;;
  
  If($page == NULL) {
  $page = one;
  }
  
  if($page == one) {
  Echo htmlheadtitlePage One/title/headbodyIt
 works!!bra
  href=\ . $defaultpage .
 index.php?page=two\Nice.../a/body/html;
  }
  
  elseif($page == two) {
  Echo htmlheadtitlePage Two/title/headbodyThis is page
 
 .
  $page .  -- a href=\ . $defaultpage . index.php
  ?page=\;D/a/body/html;
  }
  
  elseif( ($page != one) or ($page != two) or ($page != NULL) ) {
  Echo htmlheadtitleUndefined!/title/headbodypage isn't
  defined correctly!/body/html;
  }
  
  if($page == ) {
  Echo brbrbrbrbrbrbrbra href= . $defaultpage .
 Main
  Page../a;
  }
  ?
  
  Thank you,
  
  Erik Johnson
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 
 PHP Expert Consultancy in Development  http://www.indiaphp.com
 Yahoo! : consultant_php MSN : [EMAIL PROTECTED]


 




Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Zareef Ahmed
Hi Johnson,

   I am glad to know about you. In my view, PHP is one of easiest
language of world. Only one problem for beginners is the numbers of
functions in it , PHP has more than 4500 functions, ( infact, it is the
strength of PHP), so they face problems when every other person tell them
about a new function to do the same thing, but it is the part of  learning.
You just need to read something more about PHP  on sites like php.net or
w3schools.

One suggestion, first try to find out the solution of your problems, by
yourself  through  searching on the internet and old archive of  discussion
lists, because some time you may get very bad (!)  response from the group
members if you are asking very easy or normal questions.

Zareef Ahmed


- Original Message - 
From: Erik Johnson [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Sunday, December 18, 2005 10:59 AM
Subject: Re: [PHP] Someone please help me with this PHP script.


Thank you very much.  My dad is in college, but I have been teaching myself
HTML, Java, VB6, and PHP.  I've been learning to do graphical artwork with
Adobe Illustrator, and Photoshop.  I actually started programming before my
dad was in school, and I got him started I guess!  Anyway; I've learnt a
lot, and I hope to learn more, as I'm trying to make an online MMORPG /
ORPG.

Back on topic:  I looked IsSet() on PHP.net, but it didn't give that fluent
of an explanation.  Thanks!  I'll be sure to try it out.  If someone tries
my php script, and wants to make any changes, please just upload it to
ftp://lom.game-host.org/ .

Thanks again,

Erik Johnson



PHP Expert Consultancy in Development  http://www.indiaphp.com
Yahoo! : consultant_php MSN : [EMAIL PROTECTED]

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



Fwd: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Erik Johnson
 I understand that some people aren't nice to newer people that try their
hardest to figure out a problem.  Older, more experienced people see this
and they think that it's an easy fix, and that they just aren't trying, but
in essence.. they are trying just as hard as someone much more experienced.
Since they are new, they can have just as much trouble as another person, so
they deserve just as much respect in my eyes.

Anyway, I have been trying to figure out this problem, and it's just stumped
me.  It doesn't look as if anything's wrong, and other people've tested it
and it works fine.  I think I just need someone to make sure my PHP.ini file
is normal.. hence the reason I made the phpinfo() file to give much of the
information that may help.  If anyone needs it (e-mail a yes/no), and I'll
send it as an attachment.

Thanks,

Erik Johnson

(I think I just sent it to Zareef on accident. =x)


On 12/18/05, Zareef Ahmed [EMAIL PROTECTED] wrote:

 Hi Johnson,

   I am glad to know about you. In my view, PHP is one of easiest
 language of world. Only one problem for beginners is the numbers of
 functions in it , PHP has more than 4500 functions, ( infact, it is the
 strength of PHP), so they face problems when every other person tell them
 about a new function to do the same thing, but it is the part
 of  learning.
 You just need to read something more about PHP  on sites like php.net or
 w3schools.

 One suggestion, first try to find out the solution of your problems, by
 yourself  through  searching on the internet and old archive
 of  discussion
 lists, because some time you may get very bad (!)  response from the group
 members if you are asking very easy or normal questions.

 Zareef Ahmed


 - Original Message -
 From: Erik Johnson  [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Sunday, December 18, 2005 10:59 AM
 Subject: Re: [PHP] Someone please help me with this PHP script.


 Thank you very much.  My dad is in college, but I have been teaching
 myself
 HTML, Java, VB6, and PHP.  I've been learning to do graphical artwork with
 Adobe Illustrator, and Photoshop.  I actually started programming before
 my
 dad was in school, and I got him started I guess!  Anyway; I've learnt a
 lot, and I hope to learn more, as I'm trying to make an online MMORPG /
 ORPG.

 Back on topic:  I looked IsSet() on PHP.net, but it didn't give that
 fluent
 of an explanation.  Thanks!  I'll be sure to try it out.  If someone tries
 my php script, and wants to make any changes, please just upload it to
 ftp://lom.game-host.org/ .

 Thanks again,

 Erik Johnson


 
 PHP Expert Consultancy in Development  http://www.indiaphp.com
 Yahoo! : consultant_php MSN : [EMAIL PROTECTED]





Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Łukasz Hejnak

Erik Johnson napisał(a):

Okay.. I was just wondering; What's the difference between = and ==? Would
it matter if I changed them?  It seems as though if I put = instead of the
=='s, it comes up ONLY page two no matter what $page equals, and if it's ='s
instead of =='s, then it comes up with only page one no matter what $page
equals.

It's a *BIG* difference!
Because single '=' means that whatever stands at the right side of the
'=' should be assigned to whatever stands at the left side,
ie.
$a=5
doesn't compare if a is equal 5, only assignes the variable 'a' it's
value which will be 5 after this code
so if You write
if ($a=5) {...}
it will always be executed (therefore else isn't executed), as
assignment always returns true :]
so when using 'if' You always need to do
if ($a==5) {...}
unless of course Youd want to do an assingment and some code, but then
why not do
$a=5;
...
? :)

--
Best wishes
Łukasz 'Szift' Hejnak

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



Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Erik Johnson
Woohoo!  I got it to work.  Thanks everyone!  This is exactly what I needed:
making multiple-page files in one file.  It saves me the hassle of trying to
know what file is what, and where.  Instead.. one big file!

On 12/18/05, Łukasz Hejnak [EMAIL PROTECTED] wrote:

 Erik Johnson napisał(a):
  Okay.. I was just wondering; What's the difference between = and ==?
 Would
  it matter if I changed them?  It seems as though if I put = instead of
 the
  =='s, it comes up ONLY page two no matter what $page equals, and if it's
 ='s
  instead of =='s, then it comes up with only page one no matter what
 $page
  equals.
 It's a *BIG* difference!
 Because single '=' means that whatever stands at the right side of the
 '=' should be assigned to whatever stands at the left side,
 ie.
 $a=5
 doesn't compare if a is equal 5, only assignes the variable 'a' it's
 value which will be 5 after this code
 so if You write
 if ($a=5) {...}
 it will always be executed (therefore else isn't executed), as
 assignment always returns true :]
 so when using 'if' You always need to do
 if ($a==5) {...}
 unless of course Youd want to do an assingment and some code, but then
 why not do
 $a=5;
 ...
 ? :)

 --
 Best wishes
 Łukasz 'Szift' Hejnak



Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread M. Sokolewicz
Actually, I disagree with the explenation here. The reasoning behind it 
is correct, but the explenation contains a number of incorrect statements.


The = (a single '=') is the so-called assignment operator. This operator 
assigns the right-hand value to the left-hand variable. So, when you 
write $a = 5; you'll assign the right-hand value (5) to the left-hand 
variable ($a).


The  == (a double '=') is the comparation operator. This operator 
compares the right-hand value to the left-hand value, and returns the 
boolean true if it is the same, or false if it is not.


The === (a triple '=') is also a comparation operator, however this one 
is more strict. This means (in most cases) that where '==' doesn't care 
about if the left-hand value and right-hand value are of different types 
(eg. integer vs. string), this one does. So, you could say that when === 
returns true, == would also return true. However, when === returns 
false, == doesn't necesserily need to return false aswell.


Now, the assignment operator, as each operator, has a return value. And 
the return value of the assignment operator is what probably confused 
you. Basically, what happens is that the assignment operator returns 
the value it just assigned. So, if you do $a = 5; the return value will 
be 5. This is why you can do $a = $b = 5. This will be interpreted as 
being $a = ($b = 5); which means: $b = 5 returns 5, which is then 
assigned to $a, which makes $a have the value 5.
In most cases, the return value of the thing is ignored. eg. if you do 
$a = 5; 5 will be assigned to $a, and the result (5) will be returned. 
But since we don't do anything with the return value, it's silently ignored.


So, how do if() and such constructs work with this, you wonder?
if(), and most other language constructs (while(), elseif(), etc) take 
an expression as its argument, compare it to true (lazy comparing), and 
will continue if it returns true, or stop/skip if it's false.
if() could also be written as if(expression == true), where expression 
is anything with a return value (including operators!).
So, if you write if(2 == 2), the return value will be true, which equals 
true, and thus the if() will be executed. However, if you have if(3 == 
2) it'll return false (2 is NOT the same as 3), which is obviously not 
true, and thus the if() will be skipped.


When we said before, assignment operators return the value they just 
assigned, you'll see that: if($a = true) will return true, which is 
equal to true, and which will cause the if() to be executed. On the 
other side, doing if($a = false) will return false, which is not equal 
to true, and which will make PHP skip the if().
Because php uses lazy comparing in the if(), it will not check the 
type of the variable/value! This means that for the if, this is true: 
if(2 == '2'). And also if($a = 2) (all values are true, except NULL, 
false, an empty string, or zero. There is a full table showing these in 
the manual). So, doing if($a = 0) will return false, and will skip the 
if(). Of course, doing if('2' === 2) will also return false (due to the 
use of ===) and will skip the if aswell.


Hope that clears up any misunderstandings that might have been left. 
Also, I urgently recommend you to have a look at the wonderful PHP 
manual (one of THE best programming/scripting language manuals, if I may 
be so bold). A few pages which will surely help you (and also explain 
the above):

http://www.php.net/manual/en/language.operators.assignment.php
http://www.php.net/manual/en/language.operators.comparison.php
http://www.php.net/manual/en/types.comparisons.php
http://www.php.net/manual/en/language.control-structures.php
etc.

Please read the manual first, it will answer a lot of your questions.

- tul

Łukasz Hejnak wrote:

Erik Johnson napisał(a):

Okay.. I was just wondering; What's the difference between = and ==? 
Would
it matter if I changed them?  It seems as though if I put = instead of 
the
=='s, it comes up ONLY page two no matter what $page equals, and if 
it's ='s

instead of =='s, then it comes up with only page one no matter what $page
equals.


It's a *BIG* difference!
Because single '=' means that whatever stands at the right side of the
'=' should be assigned to whatever stands at the left side,
ie.
$a=5
doesn't compare if a is equal 5, only assignes the variable 'a' it's
value which will be 5 after this code
so if You write
if ($a=5) {...}
it will always be executed (therefore else isn't executed), as
assignment always returns true :]
so when using 'if' You always need to do
if ($a==5) {...}
unless of course Youd want to do an assingment and some code, but then
why not do
$a=5;
...
? :)

--
Best wishes
Łukasz 'Szift' Hejnak


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



[PHP] Someone please help me with this PHP script.

2005-12-17 Thread Erik Johnson
I do not know why this isn't working, but it would be very helpful if
someone looked over it.

?
$defaultpage = http://lom.game-host.org/uploads/erik/;;

If($page == NULL) {
$page = one;
}

if($page == one) {
Echo htmlheadtitlePage One/title/headbodyIt works!!bra
href=\ . $defaultpage . index.php?page=two\Nice.../a/body/html;
}

elseif($page == two) {
Echo htmlheadtitlePage Two/title/headbodyThis is page  .
$page .  -- a href=\ . $defaultpage . index.php
?page=\;D/a/body/html;
}

elseif( ($page != one) or ($page != two) or ($page != NULL) ) {
Echo htmlheadtitleUndefined!/title/headbodypage isn't
defined correctly!/body/html;
}

if($page == ) {
Echo brbrbrbrbrbrbrbra href= . $defaultpage . Main
Page../a;
}
?

Thank you,

Erik Johnson


Re: [PHP] Someone please help me with this PHP script.

2005-12-17 Thread Robert Cummings
On Sat, 2005-12-17 at 23:05, Erik Johnson wrote:
 I do not know why this isn't working, but it would be very helpful if
 someone looked over it.
 
 ?
 $defaultpage = http://lom.game-host.org/uploads/erik/;;
 
 If($page == NULL) {
 $page = one;
 }

What is this magical $page variable? Did you conjure it from thin air?
Or are you one of those coders still using a years old deprecated
feature called register_globals who just upgraded their version of PHP
to a version that disables it by default? Since you're the latter (yes I
can read minds from afar), then what you really want is the following
before you start using $page:

$page = isset( $_GET['page'] ) ? $_GET['page'] : null;

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Someone please help me with this PHP script.

2005-12-17 Thread Wolf
What is it doing, or not doing?

Try changing the ? to ?php and see if that works.

Robert

Erik Johnson wrote:
 I do not know why this isn't working, but it would be very helpful if
 someone looked over it.
 
 ?
 $defaultpage = http://lom.game-host.org/uploads/erik/;;
 
 If($page == NULL) {
 $page = one;
 }
 
 if($page == one) {
 Echo htmlheadtitlePage One/title/headbodyIt works!!bra
 href=\ . $defaultpage . index.php?page=two\Nice.../a/body/html;
 }
 
 elseif($page == two) {
 Echo htmlheadtitlePage Two/title/headbodyThis is page  .
 $page .  -- a href=\ . $defaultpage . index.php
 ?page=\;D/a/body/html;
 }
 
 elseif( ($page != one) or ($page != two) or ($page != NULL) ) {
 Echo htmlheadtitleUndefined!/title/headbodypage isn't
 defined correctly!/body/html;
 }
 
 if($page == ) {
 Echo brbrbrbrbrbrbrbra href= . $defaultpage . Main
 Page../a;
 }
 ?
 
 Thank you,
 
 Erik Johnson
 

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