Jump to content

IPS Shirt Design


Charles

Recommended Posts

Posted

theres issues with this, should be....



if ( $community == 'Invision Power Board' )

{

  $you = "Cool";

} else {

  $you = "n00b";

}



Either way works. Of course, it could also be if ( $you == $cool ) and refer to IPB.
  • Replies 170
  • Created
  • Last Reply
Posted

Either way works. Of course, it could also be if ( $you == $cool ) and refer to IPB.




of course in an ideal world it'd be:


if ( $community = 'Invision Power Board' )

{

  $you = "Cool";

} else {

  $you = "n00b";

}

Posted

of course in an ideal world it'd be:




if ( $community = 'Invision Power Board' )

{

  $you = "Cool";

} else {

  $you = "n00b";

}

if ( $community = 'Invision Power Board' )


Very good coder. :lol: ;)

Posted

if ( $community = 'Invision Power Board' )

Very good coder. :lol: ;)

if ( $community == 'Invision Power Board' )



*cough cough*



obviously i'm faced with newbs here (yea i said it :P). Idea was to say that everyones community always is ipb, hence "in an ideal world" :P.
Posted

What about it? It looks fine to me as far as PHP syntax is concerned.



if statements require a double equal. so if ($wolifie = "awesome") in incorrect. it should be if ($wolifie == "awesome")
Posted

if statements require a double equal. so if ($wolifie = "awesome") in incorrect. it should be if ($wolifie == "awesome")



You can do a single = in there.

It would only change how it works (ie wouldn't be comparing the value, but rather setting it and on success the condition would be true).

So in a perfect world, $community would always be set to Invision Power Board, so you wouldn't need to compare it, only set it.
Posted

Yeah, you still don't require a double == in there, a single = works fine. Try it some day.

$var = 'hello;

echo $var; // hello


if( $var = 'goodbye' )

{

echo $var; //goodbye

}

Posted

Yeah, you still don't require a double == in there, a single = works fine. Try it some day.


$var = 'hello;

echo $var; // hello


if( $var = 'goodbye' )

{

echo $var; //goodbye

}



how come every manual everywhere uses two?
Posted

Honestly, I don't know. It's probably because the chance of you needing something to evaluate to TRUE is small, and that it's not really needed.

Checked php.net though?

Posted

In most instances, you would be doing something like

if ( $imagesize = getimagesize( $filename ) )

{

  (code to parse)

}

So long as there's no error and $imagesize is filled with data, then the condition is true. Take a look at this code: http://php.net/manual/en/function.fopen.php

    if(($fh = fopen($rssFile,'w')) === FALSE){

        die('Failed to open file for writing!');

    }


It's setting $fh to be the value of the file handler and if it fails (FALSE), then it executes.

Posted

Now I do agree that a single = is pragmatically correct but I fail to see the point of doing such a thing, because the else part of the if statement will never be executed unless there is a mysterious case where $community = 'Invision Power Board' would evaluate to false. <_<

Posted

Now I do agree that a single = is pragmatically correct but I fail to see the point of doing such a thing, because the else part of the if statement will never be executed unless there is a mysterious case where $community = 'Invision Power Board' would evaluate to false. <_<



pssst, it's this thing called a joke...
Posted

And yet another topic is totally derailed.



-1 for "My other account is Wolfie"
Posted

I think Jaggi's joke went over a lot of heads :P


how come every manual everywhere uses two?




They're different things. A single = is of course an assignment operator, a double (or triple) = is a comparison operator.

This is completely valid code:

if ( $foo = bar() ) { // Is executed if bar() returns true. $foo is now true. } else { // Is executed if bar() returns false. $foo is now false. }




On the other hand:

if ( $foo == bar() ) { // Is executed if bar() returns the same value as whatever $foo is } else { // Is executed if bar() returns a different value as whatever $foo is }




Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...