Re: newbie Q: How to say, "if the fileNAME is equal to...", or better yet, "if the fileNAME ends with '.jpg'"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Should I send replies to just the list?, or is the etiquette to reply- to-all?

fun? work? you must be new :-)

new to PHP; could get boring after a long time with it, sure... but I have that 'coder's bug'... i.e. once fluent, then creatively solving problems is fun!

okay enough jokes (but now you know the list flavor at least)
Thank God! ..for lightness/humor. :-P ..esp. in these otherwise dry circles of coding!

becareful with getcwd(), look into other methods of determining
paths, e.g. dirname(__FILE__).
The page I am making needs to work in any old PHP-enabled dir we stick it in. (It's only for internal html generation, for now.)

double quotes interpolate variables, single quotes don't.

this *could* be written as:

	echo $file, '<br />';
use == to test equality, = is to set a variable.

all your time and precision will always be appreciated!


if (stripos(strrev($file), "gpj.") === 0) {
	echo $file;	
}

note the ===, 3 equals signs here is very important! check the docs for why.

== means 'equals', and === means 'is identical to'.
Seems like they would do the same thing when comparing '0' to 'the position in the string where that substr is found'. Why not?


or you could go a little more robust with regular expressions

if (preg_match("#^.*\.(jpe?g|gif|png)$#i", $file) {
	echo $file; // any image file is echo'ed
}
ahhh reg expressions. So looking forward to when I can see PHP properly/clearly enough to throw them in too! (meanwhile I better get the basics first ;-)

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux