Comparing strings doesn't work !?!?
-
Hi,
First, let me tell you that I’m modifying a theme’s file and I don’t know php.Two: I know others programing languages, so I’m not completely dummy.
I need to modify just a bit the page that displays the portfolio, so that only pictures belonging to a selected category will be shown.
But the test
If $myvariable = “mystring” fails, even if both appears to be the same string.Let me write down the actual code that I wrote just to check if the if test works (and it doesn’t):
$mycategory = get_the_term_list( $post_id, 'portfolio_category', '', ', ', '' ) ; echo $mycategory ; // output is portrait !!!! If ($mycategory == "portrait") { echo " correct" ; } else { echo " it fails" ; }The result is “it fails”
That is: on the screen, $mycategory appears to be “portrait” as expected, but the comparation with string “portrait” fails.It’s getting me crazy.
Any help ?
Tks.
[Please post code snippets between backticks or use the code button.]
The topic ‘Comparing strings doesn't work !?!?’ is closed to new replies.