|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Fri Mar 28 2008 - 06:35:46 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 28 Mar 2008 11:35:46 -0000 Issue 5372
Topics (messages 272187 through 272212):
Re: php_mssql.so
272187 by: Chris
272188 by: Liz Kim
272189 by: Alfredo CV
272190 by: Chris
munge / obfuscate ?
272191 by: Joey
272192 by: Robert Cummings
272194 by: Robert Cummings
272195 by: Colin Guthrie
272197 by: Bastien Koert
272199 by: Robert Cummings
272200 by: robert
272201 by: Robert Cummings
Re: How to install PHP 5.x on Windows Server 2000 with IIS 5 and MySQL 5.x
272193 by: Shelley
Re: Quick email address check
272196 by: Bill Guion
272198 by: Bastien Koert
convert a string to integer
272202 by: Alain Roger
272203 by: Casey
272204 by: Simon Welsh
272205 by: Alain Roger
Re: optimilize web page loading
272206 by: Zoltán Németh
272207 by: Zoltán Németh
272208 by: Zoltán Németh
272209 by: Zoltán Németh
272210 by: Peter Ford
putting variables in a variable
272211 by: Hulf
How to log APC Cache errors?
272212 by: thomas Armstrong
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Liz Kim wrote:
> We have a set of PHP files which uses "dl()" to load the extension
> "php_mssql.so" at runtime.
> These were running on a server with PHP 4.3.9 and have been recently moved
> to a new server with PHP 5.1.6 (both RedHat).
> I have tried to simply copy the file "php_mssql.so" file to the directory of
> PHP modules, however it seems to be not compatible with the new version.
Right. PHP4 is different to PHP5 internally so the extension files will
be different too.
> We dont have permissions to recompile PHP on the server but can copy files
> on the modules/extensions directory area.
> I believe we just need to get the updated "php_mssql.so" file onto the
> server.
> Any idea where I could download or how to create one?
Ideally just get the host to install the appropriate RPM's.
The only other way would be to get the same hardware (i386 compared to
amd64 for example), same version of redhat, same gcc, same php and
compile it all yourself.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Maybe I could just compile it on a test machine and copy the .so file over
to the working server.
Would there be any incompatibility issues there?
Where could I download PHP 5.1.6? I am only able to see 5.2.5 and 4.4.8 on
php.net...
Thank you!
On Thu, Mar 27, 2008 at 4:36 PM, Chris <dmagick
gmail.com> wrote:
> Liz Kim wrote:
> > We have a set of PHP files which uses "dl()" to load the extension
> > "php_mssql.so" at runtime.
> > These were running on a server with PHP 4.3.9 and have been recently
> moved
> > to a new server with PHP 5.1.6 (both RedHat).
> > I have tried to simply copy the file "php_mssql.so" file to the
> directory of
> > PHP modules, however it seems to be not compatible with the new version.
>
> Right. PHP4 is different to PHP5 internally so the extension files will
> be different too.
>
> > We dont have permissions to recompile PHP on the server but can copy
> files
> > on the modules/extensions directory area.
> > I believe we just need to get the updated "php_mssql.so" file onto the
> > server.
> > Any idea where I could download or how to create one?
>
> Ideally just get the host to install the appropriate RPM's.
>
> The only other way would be to get the same hardware (i386 compared to
> amd64 for example), same version of redhat, same gcc, same php and
> compile it all yourself.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
attached mail follows:
Hola Liz
You should go to http://rpm.pbone.net and search for php-mssql. In fact
I did it;and there you will find the php-mssql packages for both RedHat
5 and RedHat 4 and for i386 and X86_64 and even for many other linux
distributions. I upgraded my mysql to 5.0.2 and my php to 5.0.3 running
on mandrake using packages found there
Hasta pronto y éxitos.
Alfredo
Liz Kim wrote:
>We have a set of PHP files which uses "dl()" to load the extension
>"php_mssql.so" at runtime.
>These were running on a server with PHP 4.3.9 and have been recently moved
>to a new server with PHP 5.1.6 (both RedHat).
>I have tried to simply copy the file "php_mssql.so" file to the directory of
>PHP modules, however it seems to be not compatible with the new version.
>
>We dont have permissions to recompile PHP on the server but can copy files
>on the modules/extensions directory area.
>I believe we just need to get the updated "php_mssql.so" file onto the
>server.
>Any idea where I could download or how to create one?
>
>Thank you,
>LK
>
>
>
--
--------------------------------
Alfredo Covaleda Vélez
Ingeniero Agrónomo
********************************
Compre y venda sus libros en:
http://www.loslibrosusados.com
********************************
attached mail follows:
Liz Kim wrote:
> Maybe I could just compile it on a test machine and copy the .so file
> over to the working server.
> Would there be any incompatibility issues there?
If and only if:
- They are the same architecture (they both have to be i386 for example,
one can't be an amd-64 and the other be a solaris sparc).
- You have the same versions of gcc and other software. This may or may
not be the case but instead of wasting time I'd make them the same
> Where could I download PHP 5.1.6? I am only able to see 5.2.5 and 4.4.8
> on php.net...
http://www.php.net/releases/
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Hi All,
I have written an app to allow a person to go online and see a picture we
take of them. When we link to the picture I don't want it to be obvious
that the URL is
Domain.Com/Pix/123.jpg because the next person we take a picture of may be
123.jpg, so I am trying to munge/obfuscate the URL to make it less obvious.
Of course coders can figure it out, but we just want to keep out the normal
people.
Does someone have an obfuscate function which still allows the URL to work,
but doesn't allow the person to figure it out?
Thanks!
attached mail follows:
On Thu, 2008-03-27 at 21:10 -0400, Joey wrote:
> Hi All,
>
>
>
> I have written an app to allow a person to go online and see a picture we
> take of them. When we link to the picture I don't want it to be obvious
> that the URL is
>
> Domain.Com/Pix/123.jpg because the next person we take a picture of may be
> 123.jpg, so I am trying to munge/obfuscate the URL to make it less obvious.
<?php
$sekret = 'the brown cow stomped on the wittle bug';
$id = isset( $_GET['id'] ) ? (int)$_GET['id'] : 0;
$key = isset( $_GET['key'] ) ? (string)$_GET['key'] : '';
if( $key == sha1( $key.':'.$sekret ) )
{
header( 'Content-Type: image/jpg' );
readfile( "/images/not/in/web/path/$id.jpg" )
exit();
}
//
// Failure... tell them to bugger off :)
//
header( 'Content-Type: image/jpg' );
readfile( '/images/wherever/you/please/buggerOff.jpg' );
exit();
?>
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
attached mail follows:
Hi Joey,
Please keep responses on the list so others can also benefit from the
learning process.
Comments below...
On Thu, 2008-03-27 at 21:46 -0400, Joey wrote:
> > -----Original Message-----
> > From: Robert Cummings [mailto:robert
interjinn.com]
> > Sent: Thursday, March 27, 2008 9:28 PM
> > To: Joey
> > Cc: PHP
> > Subject: Re: [PHP] munge / obfuscate ?
> >
> >
> > On Thu, 2008-03-27 at 21:10 -0400, Joey wrote:
> > > Hi All,
> > >
> > >
> > >
> > > I have written an app to allow a person to go online and see a picture
> we
> > > take of them. When we link to the picture I don't want it to be obvious
> > > that the URL is
> > >
> > > Domain.Com/Pix/123.jpg because the next person we take a picture of may
> be
> > > 123.jpg, so I am trying to munge/obfuscate the URL to make it less
> obvious.
> >
> > <?php
> >
> > $sekret = 'the brown cow stomped on the wittle bug';
> >
> > $id = isset( $_GET['id'] ) ? (int)$_GET['id'] : 0;
> > $key = isset( $_GET['key'] ) ? (string)$_GET['key'] : '';
> >
> > if( $key == sha1( $key.':'.$sekret ) )
That should have been:
if( $key == sha1( $id.':'.$sekret ) )
> > {
> > header( 'Content-Type: image/jpg' );
> > readfile( "/images/not/in/web/path/$id.jpg" )
> > exit();
> > }
> >
> > //
> > // Failure... tell them to bugger off :)
> > //
> > header( 'Content-Type: image/jpg' );
> > readfile( '/images/wherever/you/please/buggerOff.jpg' );
> > exit();
> >
> > ?>
>
> Sorry to be such a newbie...
>
> I basically would call this function lets say like:
> munge( $url );
>
> end in the end be returned the munged url, however, I don't understand the
> values you have like the readfile with that url -vs- failure?
I didn't munge... I provided code for a script that sends the requested
image if it was requested with the appropriate key (presumably set
wherever the image was linked). If the key doesn't validate then another
image is presented. It can say "bugger off", it can say "not found", it
can say whatever you please. By placing the images outside the web root
and using a script like this you are virtually guaranteed the visitor
can't just request images by making a lucky guess.
Let's say the above script was called: getUserImage.php
Then you might have the following in your HTML:
<img
src="getUserImage.php?id=123&key=4fad1fea72565105d84cb187d1a3ed3bfb9aba3b" />
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
attached mail follows:
Joey wrote:
> Hi All,
>
>
>
> I have written an app to allow a person to go online and see a picture we
> take of them. When we link to the picture I don't want it to be obvious
> that the URL is
>
> Domain.Com/Pix/123.jpg because the next person we take a picture of may be
> 123.jpg, so I am trying to munge/obfuscate the URL to make it less obvious.
Just give the files a name based on a "Universally Unique Identifier".
http://en.wikipedia.org/wiki/UUID
OK, you /could/ get a clash of names, but this is a) very unlikely and
b) simple to check for.
There is a PECL module for PHP to generate these:
http://pecl.php.net/package/uuid (new version just a couple days ago
after a 4 year gap.... if that's not a sign I don't know what is!).
If you can't install the PECL module, but do have a MySQL server to hand
you can abuse it by doing:
mysql> SELECT UUID();
+--------------------------------------+
| UUID() |
+--------------------------------------+
| 14255808-4dbb-102b-a371-0015c5bd762d |
+--------------------------------------+
1 row in set (0.00 sec)
HTHs
Col
attached mail follows:
On Thu, Mar 27, 2008 at 9:10 PM, Joey <Joey
web56.net> wrote:
> Hi All,
>
>
>
> I have written an app to allow a person to go online and see a picture we
> take of them. When we link to the picture I don't want it to be obvious
> that the URL is
>
> Domain.Com/Pix/123.jpg because the next person we take a picture of may be
> 123.jpg, so I am trying to munge/obfuscate the URL to make it less
> obvious.
>
>
>
> Of course coders can figure it out, but we just want to keep out the
> normal
> people.
>
>
>
> Does someone have an obfuscate function which still allows the URL to
> work,
> but doesn't allow the person to figure it out?
>
>
>
> Thanks!
>
>
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
The solution here is to store the images in a folder above the web root and
then use a php page to read in the requested image ( a hash value should be
sufficient (eg <img
src='show_image.php?i=a1d3200086d3ec14dae1e40c50f6374f'>Click for image</a>
The show_image page can query the database for the true image name, read it
in from the folder and pass it to the page
hth
--
Bastien
Cat, the other other white meat
attached mail follows:
On Thu, 2008-03-27 at 22:36 -0400, Bastien Koert wrote:
> On Thu, Mar 27, 2008 at 9:10 PM, Joey <Joey
web56.net> wrote:
>
> > Hi All,
> >
> >
> >
> > I have written an app to allow a person to go online and see a picture we
> > take of them. When we link to the picture I don't want it to be obvious
> > that the URL is
> >
> > Domain.Com/Pix/123.jpg because the next person we take a picture of may be
> > 123.jpg, so I am trying to munge/obfuscate the URL to make it less
> > obvious.
> >
> >
> >
> > Of course coders can figure it out, but we just want to keep out the
> > normal
> > people.
> >
> >
> >
> > Does someone have an obfuscate function which still allows the URL to
> > work,
> > but doesn't allow the person to figure it out?
> >
> >
> >
> > Thanks!
> >
> >
> >
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> The solution here is to store the images in a folder above the web root and
> then use a php page to read in the requested image ( a hash value should be
> sufficient (eg <img
> src='show_image.php?i=a1d3200086d3ec14dae1e40c50f6374f'>Click for image</a>
>
> The show_image page can query the database for the true image name, read it
> in from the folder and pass it to the page
Save yourself the database trip and just stick the id AND the hash in
the URL and validate upon request.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
attached mail follows:
I like this and never would have thought to do this.
What kind performance hit does this have, if there were 100 images,
for example?
On Mar 27, 2008, at 7:02 PM, Robert Cummings wrote:
> Hi Joey,
>
> Please keep responses on the list so others can also benefit from the
> learning process.
>
> Comments below...
>
> On Thu, 2008-03-27 at 21:46 -0400, Joey wrote:
>>> -----Original Message-----
>>> From: Robert Cummings [mailto:robert
interjinn.com]
>>> Sent: Thursday, March 27, 2008 9:28 PM
>>> To: Joey
>>> Cc: PHP
>>> Subject: Re: [PHP] munge / obfuscate ?
>>>
>>>
>>> On Thu, 2008-03-27 at 21:10 -0400, Joey wrote:
>>>> Hi All,
>>>>
>>>>
>>>>
>>>> I have written an app to allow a person to go online and see a
>>>> picture
>> we
>>>> take of them. When we link to the picture I don't want it to be
>>>> obvious
>>>> that the URL is
>>>>
>>>> Domain.Com/Pix/123.jpg because the next person we take a picture
>>>> of may
>> be
>>>> 123.jpg, so I am trying to munge/obfuscate the URL to make it less
>> obvious.
>>>
>>> <?php
>>>
>>> $sekret = 'the brown cow stomped on the wittle bug';
>>>
>>> $id = isset( $_GET['id'] ) ? (int)$_GET['id'] : 0;
>>> $key = isset( $_GET['key'] ) ? (string)$_GET['key'] : '';
>>>
>>> if( $key == sha1( $key.':'.$sekret ) )
>
>
> That should have been:
>
> if( $key == sha1( $id.':'.$sekret ) )
>
>>> {
>>> header( 'Content-Type: image/jpg' );
>>> readfile( "/images/not/in/web/path/$id.jpg" )
>>> exit();
>>> }
>>>
>>> //
>>> // Failure... tell them to bugger off :)
>>> //
>>> header( 'Content-Type: image/jpg' );
>>> readfile( '/images/wherever/you/please/buggerOff.jpg' );
>>> exit();
>>>
>>> ?>
>>
>> Sorry to be such a newbie...
>>
>> I basically would call this function lets say like:
>> munge( $url );
>>
>> end in the end be returned the munged url, however, I don't
>> understand the
>> values you have like the readfile with that url -vs- failure?
>
> I didn't munge... I provided code for a script that sends the
> requested
> image if it was requested with the appropriate key (presumably set
> wherever the image was linked). If the key doesn't validate then
> another
> image is presented. It can say "bugger off", it can say "not found",
> it
> can say whatever you please. By placing the images outside the web
> root
> and using a script like this you are virtually guaranteed the visitor
> can't just request images by making a lucky guess.
>
> Let's say the above script was called: getUserImage.php
>
> Then you might have the following in your HTML:
>
> <img
> src="getUserImage.php?
> id=123&key=4fad1fea72565105d84cb187d1a3ed3bfb9aba3b" />
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
On Thu, 2008-03-27 at 22:48 -0700, robert wrote:
> I like this and never would have thought to do this.
>
> What kind performance hit does this have, if there were 100 images,
> for example?
Well... it would be like requesting 101 PHP pages :/ It would be heavy.
It's not something I'd generally use to load 100 images. The original
poster wanted it for what I presumed was a single image. If I were to
use it for 100 images I would use a different (but similar) technique
that would incurr the heavy lifting on first request and afterwards
would be as fast as a direct request to the webserver.
Cheers,
Rob.
> On Mar 27, 2008, at 7:02 PM, Robert Cummings wrote:
> > Hi Joey,
> >
> > Please keep responses on the list so others can also benefit from
> the
> > learning process.
> >
> > Comments below...
> >
> > On Thu, 2008-03-27 at 21:46 -0400, Joey wrote:
> >>> -----Original Message-----
> >>> From: Robert Cummings [mailto:robert
interjinn.com]
> >>> Sent: Thursday, March 27, 2008 9:28 PM
> >>> To: Joey
> >>> Cc: PHP
> >>> Subject: Re: [PHP] munge / obfuscate ?
> >>>
> >>>
> >>> On Thu, 2008-03-27 at 21:10 -0400, Joey wrote:
> >>>> Hi All,
> >>>>
> >>>>
> >>>>
> >>>> I have written an app to allow a person to go online and see a
> >>>> picture
> >> we
> >>>> take of them. When we link to the picture I don't want it to
> be
> >>>> obvious
> >>>> that the URL is
> >>>>
> >>>> Domain.Com/Pix/123.jpg because the next person we take a
> picture
> >>>> of may
> >> be
> >>>> 123.jpg, so I am trying to munge/obfuscate the URL to make it
> less
> >> obvious.
> >>>
> >>> <?php
> >>>
> >>> $sekret = 'the brown cow stomped on the wittle bug';
> >>>
> >>> $id = isset( $_GET['id'] ) ? (int)$_GET['id'] : 0;
> >>> $key = isset( $_GET['key'] ) ? (string)$_GET['key'] : '';
> >>>
> >>> if( $key == sha1( $key.':'.$sekret ) )
> >
> >
> > That should have been:
> >
> > if( $key == sha1( $id.':'.$sekret ) )
> >
> >>> {
> >>> header( 'Content-Type: image/jpg' );
> >>> readfile( "/images/not/in/web/path/$id.jpg" )
> >>> exit();
> >>> }
> >>>
> >>> //
> >>> // Failure... tell them to bugger off :)
> >>> //
> >>> header( 'Content-Type: image/jpg' );
> >>> readfile( '/images/wherever/you/please/buggerOff.jpg' );
> >>> exit();
> >>>
> >>> ?>
> >>
> >> Sorry to be such a newbie...
> >>
> >> I basically would call this function lets say like:
> >> munge( $url );
> >>
> >> end in the end be returned the munged url, however, I don't
> >> understand the
> >> values you have like the readfile with that url -vs- failure?
> >
> > I didn't munge... I provided code for a script that sends the
> > requested
> > image if it was requested with the appropriate key (presumably set
> > wherever the image was linked). If the key doesn't validate then
> > another
> > image is presented. It can say "bugger off", it can say "not
> found",
> > it
> > can say whatever you please. By placing the images outside the web
> > root
> > and using a script like this you are virtually guaranteed the
> visitor
> > can't just request images by making a lucky guess.
> >
> > Let's say the above script was called: getUserImage.php
> >
> > Then you might have the following in your HTML:
> >
> > <img
> > src="getUserImage.php?
> > id=123&key=4fad1fea72565105d84cb187d1a3ed3bfb9aba3b" />
> >
> > Cheers,
> > Rob.
> > --
> > http://www.interjinn.com
> > Application and Templating Framework for PHP
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
--
http://www.interjinn.com
Application and Templating Framework for PHP
attached mail follows:
On Thu, Mar 27, 2008 at 10:44 PM, Philip Thompson <philthathril
gmail.com>
wrote:
> On Mar 27, 2008, at 8:24 AM, edwardspl
ita.org.mo wrote:
>
> > Hello to All,
> >
> > Would you mind to help as the title of mail ?
> >
> > Thanks !
> >
> > Edward.
> >
>
>
> Ok, I understand that sometimes people *have* to use a certain OS, but I
> would not use IIS - Apache is your friend.
Up! Seriously up!
>
>
> As far as your question goes... have you RTFM? Here, I'll even provide you
> a link:
>
> http://php.net/manual/en/install.windows.php
>
> ~Philip
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Regards,
Shelley
attached mail follows:
At 1:28 PM -0400 3/26/08, Al wrote:
>I'm scripting a simple registry where the user can input their name
>and email address.
>
>I'd like to do a quick validity check on the email address they just
>inputted. I can check the syntax, etc. but want check if the address
>exists. I realize that servers can take a long time to bounce etc.
>I'll just deal with this separately.
>
>Is there a better way than simply sending a test email to see if it bounces?
>
>Thanks....
I've had pretty good success from the following:
after checking the syntax (exactly one
, at least one . to the right
of the
, etc.), if it passes the syntax check, I then set $rhs to
everything to the right of the
. Then I test:
if (!checkdnsrr($rhs, 'MX'))
{
invalid
}
else
{
valid
}
-----===== Bill =====-----
--
You can't tell which way the train went by looking at the track.
attached mail follows:
On Thu, Mar 27, 2008 at 10:23 PM, Bill Guion <bguion
comcast.net> wrote:
> At 1:28 PM -0400 3/26/08, Al wrote:
>
> >I'm scripting a simple registry where the user can input their name
> >and email address.
> >
> >I'd like to do a quick validity check on the email address they just
> >inputted. I can check the syntax, etc. but want check if the address
> >exists. I realize that servers can take a long time to bounce etc.
> >I'll just deal with this separately.
> >
> >Is there a better way than simply sending a test email to see if it
> bounces?
> >
> >Thanks....
>
> I've had pretty good success from the following:
>
> after checking the syntax (exactly one
, at least one . to the right
> of the
, etc.), if it passes the syntax check, I then set $rhs to
> everything to the right of the
. Then I test:
>
> if (!checkdnsrr($rhs, 'MX'))
> {
> invalid
> }
> else
> {
> valid
> }
>
> -----===== Bill =====-----
> --
>
> You can't tell which way the train went by looking at the track.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I have used this to good effect
function isEmail($email)
{
if
(eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+
[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}",$email))
{
return TRUE;
} else {
return FALSE;
}
}//end function
--
Bastien
Cat, the other other white meat
attached mail follows:
Hi,
i know this topic is obvious but i have a strange behavior and i'm getting
crazy.
my stored procedure returns me a string.
string can be an email or a message error => '-1', '-2', '-3'
when i check if the string contains only digit, i use ctype_digit(mystring)
but any way it returns me false... i suppose that for -1, -2, -3 the "-" is
taken as character and not a digit.
i tried also to cast it before into integer thanks
ctype_digit((int)mystring), but it does not work.
so how can i solve this issue ?
thx
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008
attached mail follows:
On Fri, Mar 28, 2008 at 12:48 AM, Alain Roger <raf.news
gmail.com> wrote:
> Hi,
>
> i know this topic is obvious but i have a strange behavior and i'm getting
> crazy.
>
> my stored procedure returns me a string.
> string can be an email or a message error => '-1', '-2', '-3'
>
> when i check if the string contains only digit, i use ctype_digit(mystring)
> but any way it returns me false... i suppose that for -1, -2, -3 the "-" is
> taken as character and not a digit.
> i tried also to cast it before into integer thanks
> ctype_digit((int)mystring), but it does not work.
>
> so how can i solve this issue ?
>
> thx
>
> --
> Alain
> ------------------------------------
> Windows XP SP2
> PostgreSQL 8.2.4 / MS SQL server 2005
> Apache 2.2.4
> PHP 5.2.4
> C# 2005-2008
>
is_numeric()
--
-Casey
attached mail follows:
On 28/03/2008, at 8:48, Alain Roger wrote:
> Hi,
>
> i know this topic is obvious but i have a strange behavior and i'm
> getting
> crazy.
>
> my stored procedure returns me a string.
> string can be an email or a message error => '-1', '-2', '-3'
>
> when i check if the string contains only digit, i use
> ctype_digit(mystring)
> but any way it returns me false... i suppose that for -1, -2, -3 the
> "-" is
> taken as character and not a digit.
> i tried also to cast it before into integer thanks
> ctype_digit((int)mystring), but it does not work.
>
> so how can i solve this issue ?
>
> thx
>
> --
> Alain
> ------------------------------------
> Windows XP SP2
> PostgreSQL 8.2.4 / MS SQL server 2005
> Apache 2.2.4
> PHP 5.2.4
> C# 2005-2008
is_numeric() - "Finds whether the given variable is numeric. Numeric
strings consist of optional sign, any number of digits, optional
decimal part and optional exponential part."
---
Simon Welsh
Admin of http://simon.geek.nz/
Windows is a joke operating system. Hell, it's not even an operating
system. NT is Not Tough enough for me either. 95 is how may times it
will crash an hour.
http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
attached mail follows:
thx a lot... i completly skipped this one...i don't know why :-(
now it works
On Fri, Mar 28, 2008 at 8:55 AM, Simon Welsh <simon
welsh.co.nz> wrote:
>
> On 28/03/2008, at 8:48, Alain Roger wrote:
> > Hi,
> >
> > i know this topic is obvious but i have a strange behavior and i'm
> > getting
> > crazy.
> >
> > my stored procedure returns me a string.
> > string can be an email or a message error => '-1', '-2', '-3'
> >
> > when i check if the string contains only digit, i use
> > ctype_digit(mystring)
> > but any way it returns me false... i suppose that for -1, -2, -3 the
> > "-" is
> > taken as character and not a digit.
> > i tried also to cast it before into integer thanks
> > ctype_digit((int)mystring), but it does not work.
> >
> > so how can i solve this issue ?
> >
> > thx
> >
> > --
> > Alain
> > ------------------------------------
> > Windows XP SP2
> > PostgreSQL 8.2.4 / MS SQL server 2005
> > Apache 2.2.4
> > PHP 5.2.4
> > C# 2005-2008
>
> is_numeric() - "Finds whether the given variable is numeric. Numeric
> strings consist of optional sign, any number of digits, optional
> decimal part and optional exponential part."
> ---
> Simon Welsh
> Admin of http://simon.geek.nz/
>
> Windows is a joke operating system. Hell, it's not even an operating
> system. NT is Not Tough enough for me either. 95 is how may times it
> will crash an hour.
>
> http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008
attached mail follows:
2008. 03. 27, csütörtök keltezéssel 09.29-kor Philip Thompson ezt Ãrta:
> On Mar 26, 2008, at 6:28 PM, Al wrote:
> > Depends on the server and it's load. I've strung together some
> > rather large html strings and they aways take far less time than the
> > transient time on the internet. I used to use OB extensively until
> > one day I took the time to measure the difference. I don't recall
> > the numbers; but, I do recall it was not worth the slight extra
> > trouble to use OB.
> >
> > Now, I simple assemble by html strings with $report .= "foo"; And
> > then echo $report at the end. It also makes the code very easy to
> > read and follow.
>
> You might as well take it a step further. Change the above to:
>
> $report .= 'foo';
>
> This way for literal strings, the PHP parser doesn't have to evaluate
> this string to determine if anything needs to be translated (e.g.,
> $report .= "I like to $foo"). A minimal speedup, but nonetheless...
that above statement is simply not true. parsing "foo" and 'foo' is all
the same
a good read about it:
http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html
greets,
Zoltán Németh
>
> ~Philip
>
>
> > Andrew Ballard wrote:
> >> On Wed, Mar 26, 2008 at 1:18 PM, Al <news
ridersite.org> wrote:
> >>> You are really asking an HTML question, if you think about it.
> >>>
> >>> At the PHP level, either use output buffering or assemble all your
> >>> html string as a variable and
> >>> then echo it. The goal is to compress the string into the minimum
> >>> number of packets.
> >> Yes, but do so smartly. Excessive string concatenation can slow
> >> things
> >> down as well. On most pages you probably won't notice much
> >> difference,
> >> but I have seen instances where the difference was painfully obvious.
> >> Andrew
>
attached mail follows:
2008. 03. 27, csütörtök keltezéssel 11.13-kor Jason Pruim ezt Ãrta:
> On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote:
> > Al wrote:
> >> Good point. I usually do use the single quotes, just happened to key
> >> doubles for the email.
> >>
> >> Actually, it's good idea for all variable assignments.
> >>
> >> Philip Thompson wrote:
> >>> On Mar 26, 2008, at 6:28 PM, Al wrote:
> >>>> Depends on the server and it's load. I've strung together some
> >>>> rather large html strings and they aways take far less time than
> >>>> the
> >>>> transient time on the internet. I used to use OB extensively until
> >>>> one day I took the time to measure the difference. I don't recall
> >>>> the
> >>>> numbers; but, I do recall it was not worth the slight extra trouble
> >>>> to use OB.
> >>>>
> >>>> Now, I simple assemble by html strings with $report .= "foo"; And
> >>>> then echo $report at the end. It also makes the code very easy to
> >>>> read and follow.
> >>>
> >>> You might as well take it a step further. Change the above to:
> >>>
> >>> $report .= 'foo';
> >>>
> >>> This way for literal strings, the PHP parser doesn't have to
> >>> evaluate
> >>> this string to determine if anything needs to be translated (e.g.,
> >>> $report .= "I like to $foo"). A minimal speedup, but nonetheless...
> >>>
> >>> ~Philip
> >>>
> >>>
> >>>> Andrew Ballard wrote:
> >>>>> On Wed, Mar 26, 2008 at 1:18 PM, Al <news
ridersite.org> wrote:
> >>>>>> You are really asking an HTML question, if you think about it.
> >>>>>>
> >>>>>> At the PHP level, either use output buffering or assemble all
> >>>>>> your
> >>>>>> html string as a variable and
> >>>>>> then echo it. The goal is to compress the string into the
> >>>>>> minimum
> >>>>>> number of packets.
> >>>>> Yes, but do so smartly. Excessive string concatenation can slow
> >>>>> things
> >>>>> down as well. On most pages you probably won't notice much
> >>>>> difference,
> >>>>> but I have seen instances where the difference was painfully
> >>>>> obvious.
> >>>>> Andrew
> >
> > Yes and if your script takes .00000000000000000000000000000002 seconds
> > to run using double quotes it will only take
> > .000000000000000000000000000000019 seconds with single (depending upon
> > how many quotes you have of course) :-)
>
> I'm coming in late to this thread so sorry if I missed this :)
>
> How much of a difference would it make if you have something like
> this: echo "$foo bar bar bar bar $foo $foo"; verses: echo $foo . "bar
> bar bar bar" . $foo $foo; ?In other words... You have a large
> application which is most likely to be faster? :)
if you have variables in the mix, concatenation is better than
interpolation
greets,
Zoltán Németh
>
>
> >
> >
> > -Shawn
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424-9337
> www.raoset.com
> japruim
raoset.com
>
>
>
>
attached mail follows:
2008. 03. 27, csütörtök keltezéssel 10.21-kor Shawn McKenzie ezt Ãrta:
> Jason Pruim wrote:
> >
> > On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote:
> >> Al wrote:
> >>> Good point. I usually do use the single quotes, just happened to key
> >>> doubles for the email.
> >>>
> >>> Actually, it's good idea for all variable assignments.
> >>>
> >>> Philip Thompson wrote:
> >>>> On Mar 26, 2008, at 6:28 PM, Al wrote:
> >>>>> Depends on the server and it's load. I've strung together some
> >>>>> rather large html strings and they aways take far less time than the
> >>>>> transient time on the internet. I used to use OB extensively until
> >>>>> one day I took the time to measure the difference. I don't recall the
> >>>>> numbers; but, I do recall it was not worth the slight extra trouble
> >>>>> to use OB.
> >>>>>
> >>>>> Now, I simple assemble by html strings with $report .= "foo"; And
> >>>>> then echo $report at the end. It also makes the code very easy to
> >>>>> read and follow.
> >>>>
> >>>> You might as well take it a step further. Change the above to:
> >>>>
> >>>> $report .= 'foo';
> >>>>
> >>>> This way for literal strings, the PHP parser doesn't have to evaluate
> >>>> this string to determine if anything needs to be translated (e.g.,
> >>>> $report .= "I like to $foo"). A minimal speedup, but nonetheless...
> >>>>
> >>>> ~Philip
> >>>>
> >>>>
> >>>>> Andrew Ballard wrote:
> >>>>>> On Wed, Mar 26, 2008 at 1:18 PM, Al <news
ridersite.org> wrote:
> >>>>>>> You are really asking an HTML question, if you think about it.
> >>>>>>>
> >>>>>>> At the PHP level, either use output buffering or assemble all your
> >>>>>>> html string as a variable and
> >>>>>>> then echo it. The goal is to compress the string into the minimum
> >>>>>>> number of packets.
> >>>>>> Yes, but do so smartly. Excessive string concatenation can slow
> >>>>>> things
> >>>>>> down as well. On most pages you probably won't notice much
> >>>>>> difference,
> >>>>>> but I have seen instances where the difference was painfully obvious.
> >>>>>> Andrew
> >>
> >> Yes and if your script takes .00000000000000000000000000000002 seconds
> >> to run using double quotes it will only take
> >> .000000000000000000000000000000019 seconds with single (depending upon
> >> how many quotes you have of course) :-)
> >
> > I'm coming in late to this thread so sorry if I missed this :)
> >
> > How much of a difference would it make if you have something like this:
> > echo "$foo bar bar bar bar $foo $foo"; verses: echo $foo . "bar bar bar
> > bar" . $foo $foo; ?In other words... You have a large application which
> > is most likely to be faster? :)
nope. it parses both, since you may have escaped characters within
single quotes too. so the difference only comes in when you actually
have a variable in the string.
greets,
Zoltán Németh
> >
> >
> >>
> >>
> >> -Shawn
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > --
> >
> > Jason Pruim
> > Raoset Inc.
> > Technology Manager
> > MQC Specialist
> > 3251 132nd ave
> > Holland, MI, 49424-9337
> > www.raoset.com
> > japruim
raoset.com
> >
> >
> >
> I would assume your 2 examples to be the same because the point is that
> the PHP interpreter must parse for vars to substitute when it encounters
> double-quotes whether there are any vars in it or not. With
> single-quotes the interpreter does not have to worry about it.
> Regardless, the speed diff is probably negligible, hence my flame
> inviting post. :-)
>
> -Shawn
>
attached mail follows:
2008. 03. 28, péntek keltezéssel 09.19-kor Zoltán Németh ezt Ãrta:
> 2008. 03. 27, csütörtök keltezéssel 10.21-kor Shawn McKenzie ezt Ãrta:
> > Jason Pruim wrote:
> > >
> > > On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote:
> > >> Al wrote:
> > >>> Good point. I usually do use the single quotes, just happened to key
> > >>> doubles for the email.
> > >>>
> > >>> Actually, it's good idea for all variable assignments.
> > >>>
> > >>> Philip Thompson wrote:
> > >>>> On Mar 26, 2008, at 6:28 PM, Al wrote:
> > >>>>> Depends on the server and it's load. I've strung together some
> > >>>>> rather large html strings and they aways take far less time than the
> > >>>>> transient time on the internet. I used to use OB extensively until
> > >>>>> one day I took the time to measure the difference. I don't recall the
> > >>>>> numbers; but, I do recall it was not worth the slight extra trouble
> > >>>>> to use OB.
> > >>>>>
> > >>>>> Now, I simple assemble by html strings with $report .= "foo"; And
> > >>>>> then echo $report at the end. It also makes the code very easy to
> > >>>>> read and follow.
> > >>>>
> > >>>> You might as well take it a step further. Change the above to:
> > >>>>
> > >>>> $report .= 'foo';
> > >>>>
> > >>>> This way for literal strings, the PHP parser doesn't have to evaluate
> > >>>> this string to determine if anything needs to be translated (e.g.,
> > >>>> $report .= "I like to $foo"). A minimal speedup, but nonetheless...
> > >>>>
> > >>>> ~Philip
> > >>>>
> > >>>>
> > >>>>> Andrew Ballard wrote:
> > >>>>>> On Wed, Mar 26, 2008 at 1:18 PM, Al <news
ridersite.org> wrote:
> > >>>>>>> You are really asking an HTML question, if you think about it.
> > >>>>>>>
> > >>>>>>> At the PHP level, either use output buffering or assemble all your
> > >>>>>>> html string as a variable and
> > >>>>>>> then echo it. The goal is to compress the string into the minimum
> > >>>>>>> number of packets.
> > >>>>>> Yes, but do so smartly. Excessive string concatenation can slow
> > >>>>>> things
> > >>>>>> down as well. On most pages you probably won't notice much
> > >>>>>> difference,
> > >>>>>> but I have seen instances where the difference was painfully obvious.
> > >>>>>> Andrew
> > >>
> > >> Yes and if your script takes .00000000000000000000000000000002 seconds
> > >> to run using double quotes it will only take
> > >> .000000000000000000000000000000019 seconds with single (depending upon
> > >> how many quotes you have of course) :-)
> > >
> > > I'm coming in late to this thread so sorry if I missed this :)
> > >
> > > How much of a difference would it make if you have something like this:
> > > echo "$foo bar bar bar bar $foo $foo"; verses: echo $foo . "bar bar bar
> > > bar" . $foo $foo; ?In other words... You have a large application which
> > > is most likely to be faster? :)
> > >
> > >
> > >>
> > >>
> > >> -Shawn
> > >>
> > >> --
> > >> PHP General Mailing List (http://www.php.net/)
> > >> To unsubscribe, visit: http://www.php.net/unsub.php
> > >>
> > >>
> > >
> > > --
> > >
> > > Jason Pruim
> > > Raoset Inc.
> > > Technology Manager
> > > MQC Specialist
> > > 3251 132nd ave
> > > Holland, MI, 49424-9337
> > > www.raoset.com
> > > japruim
raoset.com
> > >
> > >
> > >
> > I would assume your 2 examples to be the same because the point is that
> > the PHP interpreter must parse for vars to substitute when it encounters
> > double-quotes whether there are any vars in it or not. With
> > single-quotes the interpreter does not have to worry about it.
> > Regardless, the speed diff is probably negligible, hence my flame
> > inviting post. :-)
> >
ehh my answer is meant to be here:
nope. it parses both, since you may have escaped characters within
> single quotes too. so the difference only comes in when you actually
> have a variable in the string.
sorry its morning ;)
greets,
Zoltán Németh
> > -Shawn
> >
>
>
attached mail follows:
Eric Butera wrote:
> On Thu, Mar 27, 2008 at 12:41 PM, Peter Ford <pete
justcroft.com> wrote:
>> Jason Pruim wrote:
>> >
>> > On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote:
>> >> Al wrote:
>> >>> Good point. I usually do use the single quotes, just happened to key
>> >>> doubles for the email.
>> >>>
>> >>> Actually, it's good idea for all variable assignments.
>> >>>
>> >>> Philip Thompson wrote:
>> >>>> On Mar 26, 2008, at 6:28 PM, Al wrote:
>> >>>>> Depends on the server and it's load. I've strung together some
>> >>>>> rather large html strings and they aways take far less time than the
>> >>>>> transient time on the internet. I used to use OB extensively until
>> >>>>> one day I took the time to measure the difference. I don't recall the
>> >>>>> numbers; but, I do recall it was not worth the slight extra trouble
>> >>>>> to use OB.
>> >>>>>
>> >>>>> Now, I simple assemble by html strings with $report .= "foo"; And
>> >>>>> then echo $report at the end. It also makes the code very easy to
>> >>>>> read and follow.
>> >>>>
>> >>>> You might as well take it a step further. Change the above to:
>> >>>>
>> >>>> $report .= 'foo';
>> >>>>
>> >>>> This way for literal strings, the PHP parser doesn't have to evaluate
>> >>>> this string to determine if anything needs to be translated (e.g.,
>> >>>> $report .= "I like to $foo"). A minimal speedup, but nonetheless...
>> >>>>
>> >>>> ~Philip
>> >>>>
>> >>>>
>> >>>>> Andrew Ballard wrote:
>> >>>>>> On Wed, Mar 26, 2008 at 1:18 PM, Al <news
ridersite.org> wrote:
>> >>>>>>> You are really asking an HTML question, if you think about it.
>> >>>>>>>
>> >>>>>>> At the PHP level, either use output buffering or assemble all your
>> >>>>>>> html string as a variable and
>> >>>>>>> then echo it. The goal is to compress the string into the minimum
>> >>>>>>> number of packets.
>> >>>>>> Yes, but do so smartly. Excessive string concatenation can slow
>> >>>>>> things
>> >>>>>> down as well. On most pages you probably won't notice much
>> >>>>>> difference,
>> >>>>>> but I have seen instances where the difference was painfully obvious.
>> >>>>>> Andrew
>> >>
>> >> Yes and if your script takes .00000000000000000000000000000002 seconds
>> >> to run using double quotes it will only take
>> >> .000000000000000000000000000000019 seconds with single (depending upon
>> >> how many quotes you have of course) :-)
>> >
>> > I'm coming in late to this thread so sorry if I missed this :)
>> >
>> > How much of a difference would it make if you have something like this:
>> > echo "$foo bar bar bar bar $foo $foo"; verses: echo $foo . "bar bar bar
>> > bar" . $foo $foo; ?In other words... You have a large application which
>> > is most likely to be faster? :)
>> >
>> >
>>
>> There was a discussion about this a few weeks ago - ISTR that the compiler does
>> wierd things with double-quoted strings, something like tokenising the words and
>> checking each bit for lurking variables.
>> So in fact
>>
>>
>> echo "$foo bar bar bar bar $foo $foo";
>>
>> is slowest (because there *are* variables to interpolate,
>>
>>
>> echo $foo . " bar bar bar bar ".$foo." ".$foo;
>>
>> is a bit faster, but the double-quoted bits cause some slow-down,
>>
>>
>> echo $foo . ' bar bar bar bar '.$foo.' '.$foo;
>>
>> is a bit faster again - the single quoted bits pass through without further
>> inspection, and finally
>>
>>
>> echo $foo,' bar bar bar bar ',$foo,' ',$foo;
>>
>> is actually the fastest, because the strings are not concatenated before output.
>>
>> I think that was the overall summary - I can't locate the original post to
>> verify (or attribute) but it's in this list somewhere...
>>
>> Cheers
>>
>> --
>> Peter Ford phone: 01580 893333
>> Developer fax: 01580 893399
>> Justcroft International Ltd., Staplehurst, Kent
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Can you prove these statements with real benchmarks that are current?
> Ilia said that it is a myth that there is a performance difference
> between " and ' in one of his talks.
I found one recent post on the subject in gmane:
http://article.gmane.org/gmane.comp.php.general/169028
The poster's results are as I remembered, except that was building a string, not
echoing: possibly not quite the same.
So I tried it myself, adapting to using echo (to the ob to avaoid printing forty
million * "foo bar bar ..."). For an extra wheeze, I also tried <?=$foo?> syntax
embedded in HTML to see if that is as bad as people make out. I didn't try
HEREDOC syntax, because it is difficult to reproduce exactly the same output -
newlines get added to the output.
To get thing to run I needed to increase time out, and reduce the string to
avoid filling the PHP memory limit I have set at the moment. Here is the code:
<?php
ini_set('max_execution_time',300);
$foo = 'f';
ob_start();
$time[1] = microtime(TRUE);
for($x = 0; $x < 10000000; $x++){
echo "$foo b b b b $foo $foo";
}
$time[2] = microtime(TRUE);
ob_end_clean();
ob_start();
$time[3] = microtime(TRUE);
for($x = 0; $x < 10000000; $x++){
echo $foo . ' b b b b '.$foo.' '.$foo;
}
$time[4] = microtime(TRUE);
ob_end_clean();
ob_start();
$time[5] = microtime(TRUE);
for($x = 0; $x < 10000000; $x++){
echo $foo . " b b b b ".$foo." ".$foo;
}
$time[6] = microtime(TRUE);
ob_end_clean();
ob_start();
$time[7] = microtime(TRUE);
for($x = 0; $x < 10000000; $x++){
echo $foo,' b b b b ',$foo,' ',$foo;
}
$time[8] = microtime(TRUE);
ob_end_clean();
ob_start();
$time[9] = microtime(TRUE);
for($x = 0; $x < 10000000; $x++){
?><?=$foo?> b b b b <?=$foo?> <?=$foo?><?php
}
$time[10] = microtime(TRUE);
ob_end_clean();
echo 'For 10,000,000 loops:';
echo '<br />Interpolation:',($time[2]-$time[1]);
echo '<br />Concatenation single quote:',($time[6]-$time[5]);
echo '<br />Concatenation double quote:',($time[4]-$time[3]);
echo '<br />List:',($time[8]-$time[7]);
?>
The results are slightly different to what I expected:
For 10,000,000 loops:
Interpolation:13.385520935059
Concatenation single quote:14.523960828781
Concatenation double quote:14.472594976425
List:11.083581924438
Embedded in HTML:16.329668045044
So, it looks like for echoing at least then single quotes are actually
marginally slower than double quotes, and interpolation is faster.
Embedding in HTML *is* slower, and the comma-separated list syntax is fastest.
I suspect YMMV...
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
attached mail follows:
Hi,
I am making and HTML email. I have 3 images to put in. Currently I have
$body .="
<table>
<tr>
<td><img src=\"image1.jpg\"></td>
</tr>
<tr>
<td></td>
</tr>
</table>
";
ideally I would like to have
$myimage1 = "image1.jpg";
$myimage2 = "image2.jpg";
$myimage3 = "image3.jpg";
and put them into the HTML body variable. I have tried escaping them in
every way i can think of, dots and slashes and the rest. Any ideas?
Ross
attached mail follows:
Hi.
I'm using APC 3.0.17 with PHP 5.2.5 on Linux.
I'm suffering some "white page of death" APC errors, and I'm trying to
investigate the reasons. But:
1) I don't find any APC support forum.
2) I don't find any APC error log. I'm browsing Apache error log (with
PHP 'E_ALL' activate) and don't see any line about it.
Any suggestion is welcome. Thank you very much.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]