php-general Digest 10 Sep 2006 07:51:28 -0000 Issue 4339
Topics (messages 241545 through 241557):
Re: if statement with or comparison (newbie)
241545 by: tedd
Re: Using a variable to call another variable
241546 by: tedd
241547 by: Robert Cummings
241548 by: Martin Marques
Memcache function usage
241549 by: Chris
241553 by: Jon Anderson
Re: Newbie question about <?= ?>
241550 by: Ray Hauge
241554 by: Mike Borrelli
241555 by: Satyam
241556 by: Satyam
Re: IE session problem on one server only
241551 by: Larry Garfield
Re: Using a variable to call another variable [SOLVED]
241552 by: Dave M G
FUNCTION TO CHECK IMAGE
241557 by: BBC
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
At 12:29 PM -0400 9/9/06, Robert Cummings wrote:
On Sat, 2006-09-09 at 12:12 -0400, Mark Charette wrote:
As a senior member of the software QC department in a major industrial
company, I generally find more errors and omissions in validation
routines during code reviews and ethical hacks than anywhere else.
http://en.wikipedia.org/wiki/Appeal_to_authority
Where's Tedd, he's got the latin to go with the above link >:)
Cheers,
Rob.
Rob:
Don't throw me in that briar patch. I know the
saying "Locus ab auctoritate est infirmissimus"
may appear to fit, but I think in this case "se
méfier de l'eau qui dort" is better.
Besides:
A) I was the one that started this fire storm.
B) Mark came in and backed me up.
C) Stu, who respect greatly, surprisingly waded in on the other side.
Now, I stand cowardly between two opinions not
wanting to offend either, nor embarrass myself
publicly, which I do often enough anyway.
However with that said, my original question/statement still stands.
I realize (AS WE ALL DO), that *all* data coming
from outside *must* be sanitized -- BUT -- using
$_REQUEST still does not provide as much
information as to where the data came from as the
use of $_GET, $_POST, and $_COOKIE -- that's an
unarguable fact, is it not?
This thread was like an old-west circled wagon
train with everyone inside expounding about the
obvious dangers of an Indian attack* but failing
to listen to some who are saying "They're
attacking from the West", while arguing it's not
important to know which way the attack comes. I
think some just misread the point of the post.
tedd (as he scurries around to the east side of a rock while dodging arrows)
*In keeping with current Political correctness,
it was an US "Indian" attack -- also note the
attack was from the West and not from the East.
:-)
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
At 11:19 AM -0400 9/9/06, Robert Cummings wrote:
> > Or something like that. <---- :-)
$easy_peasyier = array("foo1" => 1, "foo2" => 2, "foo3" => 3);
echo($easy_peasyier['foo1']);
That's zero marks on any exam I ever wrote. You didn't properly read the
business requirements that specified the need for a function ;) Also,
the version you showed isn't shared in any way, it has local scope, so
unless it's defined in global scope and you're working in global scope
(since I don't see a global declaration) then it's not very
accessible :))
Cheers,
Rob.
Rob:
If you ever wrote an exam that said at the end of a question --
"Or something like that."
-- then you would have gotten an answer like mine.
I've been dodging teachers longer than you've been one. :-)
tedd
PS: Few things are harder to put up with than the annoyance of a good example.
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On Sat, 2006-09-09 at 16:05 -0400, tedd wrote:
> At 11:19 AM -0400 9/9/06, Robert Cummings wrote:
> >
> > > > Or something like that. <---- :-)
> >>
> >> $easy_peasyier = array("foo1" => 1, "foo2" => 2, "foo3" => 3);
> >>
> >> echo($easy_peasyier['foo1']);
> >
> >That's zero marks on any exam I ever wrote. You didn't properly read the
> >business requirements that specified the need for a function ;) Also,
> >the version you showed isn't shared in any way, it has local scope, so
> >unless it's defined in global scope and you're working in global scope
> >(since I don't see a global declaration) then it's not very
> >accessible :))
> >
> >Cheers,
> >Rob.
>
> Rob:
>
> If you ever wrote an exam that said at the end of a question --
>
> "Or something like that."
>
> -- then you would have gotten an answer like mine.
-5 Argumentation *haha*.
> I've been dodging teachers longer than you've been one. :-)
I'm not a teacher, and if I were, I'd most certanly only have a few to
choose from my history that I considered good teachers.
Grab some popcorn for a little story...
I have an especial disdain for this one teacher in grade 12 that
forced the whole class to write points on 4x6 cards for an essay we had
to write. Each week she'd check the stack. So you'd see the smug looks
on the annoying people that thought writing down hundreds of snippets
was good work. I on the other hand was doing mine on the 9 wonders of
the world, I had 9 cards. She really didn't find that amusing,
especially since week one I had 9 cards, and on week 4 I had 9 cards
unchanged. When I got my essay back I got 75%. 25 for the intro, 25 for
the body, 25 for the conclusion, and 0 for content... oh the bitterness
she had for me.
> PS: Few things are harder to put up with than the annoyance of a good example.
You feel that way about my example? Awwwww! ;)
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. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
On Sat, 09 Sep 2006 08:55:35 -0500, Christopher Weldon <[EMAIL PROTECTED]>
wrote:
>
> class myClass {
> private var $_001;
> private var $_002;
> private var $_003;
>
> public function access_var($var) {
> return $this->$$var;
> }
> }
>
> $cs = new myClass;
> $cs->access_var('_001');
How about call a function whose name is returned from the function myFunc()? :-D
Ansewer:
{myFunc()}()
My 2 cents.
--
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
---------------------------------------------------------
--- End Message ---
--- Begin Message ---
Hi,
I'm trying to use memcache (
http://uk2.php.net/manual/en/function.memcache-add.php ) but I'm having a
problem.
When using the add/set functions I want to set an expire time, but dont want
the data to be compressed (using small strings it seems silly to try to and
compress), what do I put for flags to allow me to use the extra expire
parameter?
Thanks,
Chris.
--- End Message ---
--- Begin Message ---
Chris wrote:
Hi,
I'm trying to use memcache (
http://uk2.php.net/manual/en/function.memcache-add.php ) but I'm having a
problem.
When using the add/set functions I want to set an expire time, but dont want
the data to be compressed (using small strings it seems silly to try to and
compress), what do I put for flags to allow me to use the extra expire
parameter?
Just pass NULL or 0 as the flags argument, and pass the expiry time as
usual. E.g. $obj->add/set($var,$val,0,$expiry)
jon
--- End Message ---
--- Begin Message ---
On Saturday 09 September 2006 08:19, Mike Borrelli wrote:
> Good day,
>
> While I've been using php for more than a little while now, I've never
> understood why the use of the "<?= ...?>" short tag is noted "to be
> avoided".
>
> Or rather, I understand that there's an option to disable it, and that's
> why it's noted in this way, but I don't understand why it's disabled?
> What's gained by writing <?php echo some_function(); ?> over <?=
> some_function(); ?>
>
> Thanks in advance.
>
> Cheers,
> Mike
As was said before, the major reasons for not using short tags are:
1) Not everyone has access to the ini file, and might not be able to use short
tags. If you're releasing your code to the public, you want to work in as
many places as possible, so then you should use <?php instead.
2) when using XML files, they use <?xml, and the <? is recognized as the start
of a PHP block, but the following syntax will be correct and your code will
fail. I have seen that someone suggested having PHP recognize <?xml as not
being a PHP short tag, but I don't remember where off the top of my head.
This does bring up an interesting idea though. It appears that <?php= is not
valid. A lot of people use <?= as a sort of templating system instead of
adding the complexity of smarty or other templating systems (which are fine).
Is it possible, or will it be possible, to use <?php="blah" ?>
--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099
--- End Message ---
--- Begin Message ---
Okay, after thinking about it, and looking at the replies, it seems as
though there is only one situation where the short tags break things, and
that's in XML with the <? ?> pair being valid for XML.
Yes, enabling the short tags is in the ini file, but is it on by default
and require effort to change?
That's the real question, I think. Not, why shouldn't I use them the way
they are, but why is it that the <?= ?> tag isn't designed into the
language to be acceptable?
Honestly, the <? ?> pair just feels a little lazy, since all you save are
the 4 characters "php ", and all the code inside is the same. The <?= ?>
tag gives you 7 characters free and does something unique.
The situation I think of using it the most in is something such as:
<li><a href="<?= $post->permLink; ?>">...</a></li>
Which looks cleaner, in my opinion, than:
<li><a href="<?php print $post->permLink; ?>">...</a></li>
Not a whole lot larger, no, and perhaps you might say, Well, the second
way is more explicit! Yes.
Also, shouldn't it be possible to check for <?= ?> and, based on the '='
there, pop out of the parser if it comes across <?xml...?> ?
Cheers,
Mike
> As was said before, the major reasons for not using short tags are:
>
> 1) Not everyone has access to the ini file, and might not be able to use
> short
> tags. If you're releasing your code to the public, you want to work in as
> many places as possible, so then you should use <?php instead.
>
> 2) when using XML files, they use <?xml, and the <? is recognized as the
> start
> of a PHP block, but the following syntax will be correct and your code
> will
> fail. I have seen that someone suggested having PHP recognize <?xml as
> not
> being a PHP short tag, but I don't remember where off the top of my head.
>
> This does bring up an interesting idea though. It appears that <?php= is
> not
> valid. A lot of people use <?= as a sort of templating system instead of
> adding the complexity of smarty or other templating systems (which are
> fine).
> Is it possible, or will it be possible, to use <?php="blah" ?>
>
> --
> Ray Hauge
> Programmer/Systems Administrator
> American Student Loan Services
> www.americanstudentloan.com
> 1.800.575.1099
>
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "Mike Borrelli" <[EMAIL PROTECTED]>
To: "Ray Hauge" <[EMAIL PROTECTED]>
Cc: <[email protected]>; "Mike Borrelli" <[EMAIL PROTECTED]>
Sent: Sunday, September 10, 2006 6:52 AM
Subject: Re: [PHP] Newbie question about <?= ?>
Okay, after thinking about it, and looking at the replies, it seems as
though there is only one situation where the short tags break things, and
that's in XML with the <? ?> pair being valid for XML.
As I said <? ?> is not valid XML, it misses the code to identify the
processor to deal with the contents. XML expects what it calls a PITarget
(PI being Processing Instruction, which is what this <?PITarget ?> pair is)
right after the first question mark.
Yes, enabling the short tags is in the ini file, but is it on by default
and require effort to change?
That's the real question, I think. Not, why shouldn't I use them the way
they are, but why is it that the <?= ?> tag isn't designed into the
language to be acceptable?
Which language? If it only was for PHP, anything could be designed into
it, but it does not have the environment all to itself and it might have to
coexist with other standards. XML requires the PITarget, and that's it.
Nevertheless, you are not required to be XML compatible in your setup and
indeed, in most cases, this is irrelevant.
Honestly, the <? ?> pair just feels a little lazy, since all you save are
the 4 characters "php ", and all the code inside is the same. The <?= ?>
tag gives you 7 characters free and does something unique.
The situation I think of using it the most in is something such as:
<li><a href="<?= $post->permLink; ?>">...</a></li>
Which looks cleaner, in my opinion, than:
<li><a href="<?php print $post->permLink; ?>">...</a></li>
Not a whole lot larger, no, and perhaps you might say, Well, the second
way is more explicit! Yes.
Also, shouldn't it be possible to check for <?= ?> and, based on the '='
there, pop out of the parser if it comes across <?xml...?> ?
xml is not the only valid PITarget out there, thus, you cannot parse
everything but xml since the list of 'buts' is endless. Anyway, if you care
for XML compatibility , it is important that the <?xml PI is in clear text
at the beginning and that you don't use short tags, otherwise if you do not
care for compatibility, then the <?xml can be echoed from within php as a
normal string, which is a good thing since, after all, the <?xml in clear
text at the beginning is announcing that the whole document is xml
compatible which, with short tags enabled, it is not. The output of that
script, which would include the echoed <?xml, would be XML compatible.
I personally don't care much for XML compatibility in my PHP scripts, I care
that the output of those scripts is XML compatible, if it has to. I still
think the recomendation is valid though I am still to see any place which
would deny itself the chance to run zillions of packages out there to
achieve some theoretical compatibility at a point (PHP source code) where it
is irrelevant.
Satyam
Cheers,
Mike
As was said before, the major reasons for not using short tags are:
1) Not everyone has access to the ini file, and might not be able to use
short
tags. If you're releasing your code to the public, you want to work in
as
many places as possible, so then you should use <?php instead.
2) when using XML files, they use <?xml, and the <? is recognized as the
start
of a PHP block, but the following syntax will be correct and your code
will
fail. I have seen that someone suggested having PHP recognize <?xml as
not
being a PHP short tag, but I don't remember where off the top of my head.
This does bring up an interesting idea though. It appears that <?php= is
not
valid. A lot of people use <?= as a sort of templating system instead of
adding the complexity of smarty or other templating systems (which are
fine).
Is it possible, or will it be possible, to use <?php="blah" ?>
--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "Mike Borrelli" <[EMAIL PROTECTED]>
To: "Ray Hauge" <[EMAIL PROTECTED]>
Cc: <[email protected]>; "Mike Borrelli" <[EMAIL PROTECTED]>
Sent: Sunday, September 10, 2006 6:52 AM
Subject: Re: [PHP] Newbie question about <?= ?>
Okay, after thinking about it, and looking at the replies, it seems as
though there is only one situation where the short tags break things, and
that's in XML with the <? ?> pair being valid for XML.
As I said <? ?> is not valid XML, it misses the code to identify the
processor to deal with the contents. XML expects what it calls a PITarget
(PI being Processing Instruction, which is what this <?PITarget ?> pair is)
right after the first question mark.
Yes, enabling the short tags is in the ini file, but is it on by default
and require effort to change?
That's the real question, I think. Not, why shouldn't I use them the way
they are, but why is it that the <?= ?> tag isn't designed into the
language to be acceptable?
Which language? If it only was for PHP, anything could be designed into
it, but it does not have the environment all to itself and it might have to
coexist with other standards. XML requires the PITarget, and that's it.
Nevertheless, you are not required to be XML compatible in your setup and
indeed, in most cases, this is irrelevant.
Honestly, the <? ?> pair just feels a little lazy, since all you save are
the 4 characters "php ", and all the code inside is the same. The <?= ?>
tag gives you 7 characters free and does something unique.
The situation I think of using it the most in is something such as:
<li><a href="<?= $post->permLink; ?>">...</a></li>
Which looks cleaner, in my opinion, than:
<li><a href="<?php print $post->permLink; ?>">...</a></li>
Not a whole lot larger, no, and perhaps you might say, Well, the second
way is more explicit! Yes.
Also, shouldn't it be possible to check for <?= ?> and, based on the '='
there, pop out of the parser if it comes across <?xml...?> ?
xml is not the only valid PITarget out there, thus, you cannot parse
everything but xml since the list of 'buts' is endless. Anyway, if you care
for XML compatibility , it is important that the <?xml PI is in clear text
at the beginning and that you don't use short tags, otherwise if you do not
care for compatibility, then the <?xml can be echoed from within php as a
normal string, which is a good thing since, after all, the <?xml in clear
text at the beginning is announcing that the whole document is xml
compatible which, with short tags enabled, it is not. The output of that
script, which would include the echoed <?xml, would be XML compatible.
I personally don't care much for XML compatibility in my PHP scripts, I care
that the output of those scripts is XML compatible, if it has to. I still
think the recomendation is valid though I am still to see any place which
would deny itself the chance to run zillions of packages out there to
achieve some theoretical compatibility at a point (PHP source code) where it
is irrelevant.
Satyam
Cheers,
Mike
As was said before, the major reasons for not using short tags are:
1) Not everyone has access to the ini file, and might not be able to use
short
tags. If you're releasing your code to the public, you want to work in
as
many places as possible, so then you should use <?php instead.
2) when using XML files, they use <?xml, and the <? is recognized as the
start
of a PHP block, but the following syntax will be correct and your code
will
fail. I have seen that someone suggested having PHP recognize <?xml as
not
being a PHP short tag, but I don't remember where off the top of my head.
This does bring up an interesting idea though. It appears that <?php= is
not
valid. A lot of people use <?= as a sort of templating system instead of
adding the complexity of smarty or other templating systems (which are
fine).
Is it possible, or will it be possible, to use <?php="blah" ?>
--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Friday 08 September 2006 06:06, Alex Turner wrote:
> > We had issues before with the session not working correctly in IE, but I
> > fixed those with info from the php.net manual user comments. I'm at a
> > loss as to why it's only happening on the one server and not the other
> > now. If it were the other way around I wouldn't care, but the live site
> > shouldn't break. :-)
> >
> > Any idea what could be the problem?
>
> It sounds like the IE is putting different security/cookie settings for
> your local and remote site.
We get the same symptoms from multiple systems. I get it on my work
desktop, and on the client's desktop in another city.
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
--- End Message ---
--- Begin Message ---
Martin, Tedd, Robert, Christopher,
Thank you all for your advice and examples.
I had not been aware that it was possible to simply add another "$"
ahead of the variable, to make a variable of the variable's name.
And especially thank you for expressing an example in terms of a class
and method, which is my ultimate intent with this process.
I will also make sure to name my variables with at least one leading
alphabet character. Thanks for the warning.
All your time and expert advice is much appreciated.
--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2
--- End Message ---
--- Begin Message ---
Hi all.
I'm having a problem regarding image handling. Sometimes an image can be showed
in browser normally (in my computer) but when I
upload it into my site that image is not valid, so there is an issue in my
getimagesizes() function.
Is there any function to recover such problem? I used
"if(file_exists($image_path))" but it couldn't solve the problem.
Input would be appreciated
Best Regards
============BBC============
**o<0>o**
--- End Message ---