|
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 Feb 29 2008 - 19:36:51 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 1 Mar 2008 01:36:51 -0000 Issue 5322
Topics (messages 270729 through 270788):
Re: imagettftext and utf-8 (swedish characters)
270729 by: Frank Arensmeier
270746 by: Daniel Brown
270747 by: Daniel Brown
270748 by: Jochem Maas
270749 by: Jochem Maas
270751 by: Jochem Maas
270752 by: Daniel Brown
270753 by: Jochem Maas
270754 by: Daniel Brown
270785 by: David Sveningsson
270786 by: David Sveningsson
270787 by: David Sveningsson
Re: Getting the name of a function
270730 by: Jochem Maas
270732 by: Daniel Brown
Re: auto-wrap on posts
270731 by: Ray Hauge
270745 by: Daniel Brown
Re: Text Color
270733 by: Daniel Brown
270734 by: Richard Heyes
270736 by: Jason Pruim
270737 by: Andrew Ballard
270739 by: Daniel Brown
270741 by: Jason Pruim
Re: What design patterns do you usually use?
270735 by: tedd
270738 by: Zoltán Németh
270757 by: tedd
270771 by: Jochem Maas
270782 by: Zoltán Németh
270784 by: Ray Hauge
Re: output buffering in CLI script.
270740 by: Greg Donald
270743 by: Jochem Maas
Re: Get country from Phone number
270742 by: Robert Cummings
270744 by: Daniel Brown
270788 by: Jim Lucas
Re: simple command help
270750 by: Daniel Brown
Re: Making sure an include file works
270755 by: Daniel Brown
270758 by: Thiago Pojda
270759 by: Richard S. Crawford
270762 by: Richard Heyes
270763 by: Daniel Brown
270767 by: Jochem Maas
270769 by: Daniel Brown
Re: echo returnArray()['a']; // workaround
270756 by: Shawn McKenzie
Re: dont print echo
270760 by: Shawn McKenzie
270761 by: Daniel Brown
270766 by: Jim Lucas
270768 by: Daniel Brown
Re: Cannot even come up with the beginning of a regex
270764 by: Dotan Cohen
Re: Sessions
270765 by: Daniel Brown
270783 by: Warren Vail
string effect
270770 by: Alain Roger
270774 by: Greg Donald
270777 by: Greg Donald
php with modified version of sqlite
270772 by: Jean-Christophe Roux
270775 by: Greg Donald
Posting Summary for Week Ending 29 February, 2008: php-general
lists.php.net
270773 by: PostTrack [Dan Brown]
Weird Results from Curl
270776 by: Wolf
270778 by: Ray Hauge
270779 by: Wolf
270780 by: Ray Hauge
270781 by: Wolf
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:
29 feb 2008 kl. 03.41 skrev David Sveningsson:
> Nathan Rixham skrev:
>> before going any further, your HTML page is in UTF-8 yes? with the
>> appropriate content-type line.
>
> Yes, apache uses only utf-8 as charset and the html content-type
> meta tag is set to utf-8 too. Also, the html form validates at
> validator.w3.org
>
>> plus: first debugging step:
>> function preview(){
>> $title = html_entity_decode($_GET['title'], ENT_COMPAT, 'UTF-8');
>> print_r($title); #verify in view source / web browser that data is
>> correct before it's sent to imagettftext
>
> I see the characters correctly, and page info in firefox says the
> encoding is utf-8.
>
From the man page:
"If a character is used in the string which is not supported by the
font, a hollow rectangle will replace the character."...
If you are 100% sure that the var $title contains a valid UTF-8
encoded text sting (simply output the string to the browser and set
the page encoding to UTF-8), then the only thing that is left that
might screw up the text-to-image output is the font you are using. As
you might know, you can only use TrueType fonts.
//frank
ps sorry for posting my reply off-list the first time... ds.
attached mail follows:
On Thu, Feb 28, 2008 at 9:17 PM, Nathan Rixham <nrixham
gmail.com> wrote:
> before going any further, your HTML page is in UTF-8 yes? with the
> appropriate content-type line.
That wouldn't matter, Nate. It's an image (and already rendered
as a static graphical object). Page encoding won't make a difference
here.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
On Thu, Feb 28, 2008 at 8:45 PM, David Sveningsson <ext
sidvind.com> wrote:
> Hi, I've ran into some problems when outputing text to an image using
> imagettftext. I cannot get swedish characters to work, I just get a
> square. I've tried different fonts which I know has those characters
> (bitstream vera, arial, times new roman, etc). What am I doing wrong?
Most likely, it's because the font doesn't have an entry for those
characters. Try to find a TTF font that does have those entities and
your problems will most likely be solved that easily.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
David Sveningsson schreef:
> Hi, I've ran into some problems when outputing text to an image using
> imagettftext. I cannot get swedish characters to work, I just get a
> square. I've tried different fonts which I know has those characters
> (bitstream vera, arial, times new roman, etc). What am I doing wrong?
>
> I know I must pass utf-8 encoded text and I belive I do but I don't know
> how to check it.
>
> HTML form code:
> (html document uses utf-8 as charset and apache is set to use utf-8 too)
>
> <form action="/index.php/slides/upload" method="post"
> accept-charset="utf-8">
> <input type="text" id="title" name="title" size="70" value="" />
> </form>
>
> /index.php/slides/upload:
>
> $title = htmlentities($_POST['title'], ENT_COMPAT, 'UTF-8');
> $image =
> '/index.php/slides/preview?title='.urlencode($title).'&content='.urlencode($_POST['content']);
>
>
> /index.php/slides/preview:
>
> function preview(){
> $title = html_entity_decode($_GET['title'], ENT_COMPAT, 'UTF-8');
> //$title = $_GET['title'];
>
> ///
note Hardcoded resolution
> $im = imagecreatetruecolor(800, 600);
> $black = imagecolorallocate($im, 0, 0, 0);
> $white = imagecolorallocate($im, 255, 255, 255);
> $font = "/usr/share/fonts/corefonts/georgia.ttf";
>
> $title_size = 32;
>
> imagefilledrectangle($im, 0, 0, 800, 600, $black);
>
> imagettftext( $im, $title_size, 0, 50, 50, $white, $font, $title );
>
> header("Content-Type: image/png");
> imagepng($im);
> exit();
> }
have you tried a test script (file encoded as UTF8) where you hardcode the
title string and see if that also outputs 'squares' ... at least that way
you can be sure whether the problem is in some kind of encoding mush that occurs
during the title's roundtrip of server -> browser -> server OR whether the problem is
actually to do with imagetfftext.
>
attached mail follows:
Daniel Brown schreef:
> On Thu, Feb 28, 2008 at 9:17 PM, Nathan Rixham <nrixham
gmail.com> wrote:
>> before going any further, your HTML page is in UTF-8 yes? with the
>> appropriate content-type line.
>
> That wouldn't matter, Nate. It's an image (and already rendered
> as a static graphical object). Page encoding won't make a difference
> here.
it does because he's passing the title as an argument to the image script:
<img src="/hisimgscript.php?title=foodledoodle" />
okay, so foodledoodle is not proper swedish, but if you say it in a high
voice it sounds a bit like it :-P
>
attached mail follows:
Jochem Maas schreef:
> David Sveningsson schreef:
>> Hi, I've ran into some problems when outputing text to an image using
>> imagettftext. I cannot get swedish characters to work, I just get a
>> square. I've tried different fonts which I know has those characters
>> (bitstream vera, arial, times new roman, etc). What am I doing wrong?
>>
>> I know I must pass utf-8 encoded text and I belive I do but I don't
>> know how to check it.
>>
>> HTML form code:
>> (html document uses utf-8 as charset and apache is set to use utf-8 too)
>>
>> <form action="/index.php/slides/upload" method="post"
>> accept-charset="utf-8">
>> <input type="text" id="title" name="title" size="70" value="" />
>> </form>
>>
>> /index.php/slides/upload:
>>
>> $title = htmlentities($_POST['title'], ENT_COMPAT, 'UTF-8');
>> $image =
>> '/index.php/slides/preview?title='.urlencode($title).'&content='.urlencode($_POST['content']);
>>
>>
>> /index.php/slides/preview:
>>
>> function preview(){
>> $title = html_entity_decode($_GET['title'], ENT_COMPAT, 'UTF-8');
>> //$title = $_GET['title'];
>>
>> ///
note Hardcoded resolution
>> $im = imagecreatetruecolor(800, 600);
>> $black = imagecolorallocate($im, 0, 0, 0);
>> $white = imagecolorallocate($im, 255, 255, 255);
>> $font = "/usr/share/fonts/corefonts/georgia.ttf";
>>
>> $title_size = 32;
>>
>> imagefilledrectangle($im, 0, 0, 800, 600, $black);
>>
>> imagettftext( $im, $title_size, 0, 50, 50, $white, $font, $title );
>> header("Content-Type: image/png");
>> imagepng($im);
>> exit();
>> }
>
> have you tried a test script (file encoded as UTF8) where you hardcode the
> title string and see if that also outputs 'squares' ... at least that way
> you can be sure whether the problem is in some kind of encoding mush
> that occurs
> during the title's roundtrip of server -> browser -> server OR whether
> the problem is
> actually to do with imagetfftext.
I tried in on my local machine (php5.2.5) and I can output swedish characters
no problem (I hope the below test script comes through with borking the
UTF-8 chars)
<?php
set_time_limit(0);
//$title = html_entity_decode($_GET['title'], ENT_COMPAT, 'UTF-8');
//$title = 'åååååååå bork';
//$title = 'Pippi Långstrump går om bord';
/*
$title = 'Alla människor är födda fria
och lika i värde och rättigheter.
De är utrustade med förnuft och
samvete och bör handla gentemot
varandra i en anda av broderskap.';
//*/
$title = 'hå kå Å å Ä ä Ö ö å ö';
///
note Hardcoded resolution
$im = imagecreatetruecolor(400, 200);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
//$font = "/Applications/OpenOffice.org 2.3.app/Contents/share/fonts/truetype/Georgia.ttf";
$font = "/Library/Fonts/Georgia.ttf";
$title_size = 18;
imagefilledrectangle($im, 0, 0, 800, 600, $black);
imagettftext( $im, $title_size, 0, 20, 40, $white, $font, $title );
header("Content-Type: image/png");
imagepng($im);
exit();
>
>
>>
>
attached mail follows:
On Fri, Feb 29, 2008 at 12:59 PM, Jochem Maas <jochem
iamjochem.com> wrote:
> it does because he's passing the title as an argument to the image script:
I would say that's what I get for skimming, but look here:
> <form action="/index.php/slides/upload" method="post" accept-charset="utf-8">
The form accepts (expects) UTF-8 (though the OP may be better with
`latin1_swedish_ci`).
Page encoding would only come into play here if the data was
written as an HTML string. Form elements generally don't give a damn
how the rest of the page is configured, because their job is only to
be a container to pass POST and GET data to the server (which, again,
couldn't care less what the previous page's encoding was prior to
receiving the new data).
The only places it will matter in this case, and in order, are:
1.) The FORM element (properly configured)
2.) The browser's capability to send data encoded in the
desired encoding (likely true with the OP)
3.) The server's ability to handle the encoding (again,
properly configured, according to David)
Thus, it leads me back to my previous guess that the font he chose
(georgia.ttf) doesn't have Swedish characters in the set. With that,
I'm not sure, though, because I don't have the Georgia font pack on
here, so it'll have to stay as a guess for now.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Daniel Brown schreef:
> On Fri, Feb 29, 2008 at 12:59 PM, Jochem Maas <jochem
iamjochem.com> wrote:
>> it does because he's passing the title as an argument to the image script:
>
> I would say that's what I get for skimming, but look here:
I guess I skimmed somewhat too ... but I based my assumption on the following from the
OPs post:
/index.php/slides/upload:
$title = htmlentities($_POST['title'], ENT_COMPAT, 'UTF-8');
$image = '/index.php/slides/preview?title='.urlencode($title).'&content='.urlencode($_POST['content']);
so the script handle the form submission looks to be generating a url
used as the src of an img.
...
>
> Thus, it leads me back to my previous guess that the font he chose
> (georgia.ttf) doesn't have Swedish characters in the set. With that,
> I'm not sure, though, because I don't have the Georgia font pack on
> here, so it'll have to stay as a guess for now.
Georgia.tff should cover swedish characters - atleast it does on my
system (MPB) ... my little test script in my other post on this thread
works for me ... I have no idea if one should/could expect variations
of supported characters in a TTF font file depending on the system your
on (my guess would be you could rely on all systems that have said TTF file
to support the same chars - I assume that although it may be compiled diffferently
for different platforms the source font definition is going to be the same)
attached mail follows:
On Fri, Feb 29, 2008 at 1:31 PM, Jochem Maas <jochem
iamjochem.com> wrote:
> (my guess would be you could rely on all systems that have said TTF file
> to support the same chars - I assume that although it may be compiled diffferently
> for different platforms the source font definition is going to be the same)
I'm just blindly assuming (yes, ASS-uming) that the TTFs must be
the same regardless, considering the portability across platforms.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Frank Arensmeier skrev:
> 29 feb 2008 kl. 03.41 skrev David Sveningsson:
>
>> Nathan Rixham skrev:
>>> before going any further, your HTML page is in UTF-8 yes? with the
>>> appropriate content-type line.
>>
>> Yes, apache uses only utf-8 as charset and the html content-type meta
>> tag is set to utf-8 too. Also, the html form validates at
>> validator.w3.org
>>
>>> plus: first debugging step:
>>> function preview(){
>>> $title = html_entity_decode($_GET['title'], ENT_COMPAT, 'UTF-8');
>>> print_r($title); #verify in view source / web browser that data is
>>> correct before it's sent to imagettftext
>>
>> I see the characters correctly, and page info in firefox says the
>> encoding is utf-8.
>>
>
> From the man page:
> "If a character is used in the string which is not supported by the
> font, a hollow rectangle will replace the character."...
> If you are 100% sure that the var $title contains a valid UTF-8
> encoded text sting (simply output the string to the browser and set
> the page encoding to UTF-8), then the only thing that is left that
> might screw up the text-to-image output is the font you are using. As
> you might know, you can only use TrueType fonts.
I am quite sure that the font supports the characters. I tried a couple
of fonts that I use in other programs with utf-8. I am, however, not
100% sure that $title is correct utf-8, but I think it is.
attached mail follows:
Jochem Maas skrev:
> I guess I skimmed somewhat too ... but I based my assumption on the
> following from the
> OPs post:
>
> /index.php/slides/upload:
>
> $title = htmlentities($_POST['title'], ENT_COMPAT, 'UTF-8');
> $image =
> '/index.php/slides/preview?title='.urlencode($title).'&content='.urlencode($_POST['content']);
>
>
> so the script handle the form submission looks to be generating a url
> used as the src of an img.
>
Yes, the script generates an url to the script that renders the image.
$image is later used in an img-tag. Maybe there is another way to solve
this but this was the only thing I could think of.
I have noted that if I use numerical html entities for åäö (Å for
instance) I can see the characters correctly. I guess that would mean
the string passed is *not* correct utf-8.
Here is the current source:
$title = htmlentities( stripslashes($_POST['title']), ENT_NOQUOTES,
"utf-8" );
$content = htmlentities( stripslashes($_POST['content']), ENT_NOQUOTES,
"utf-8" );
$image =
'/index.php/slides/preview?title='.urlencode($title).'&content='.urlencode($content)."&align=$align";
...
$title = html_entity_decode(get('title'), ENT_NOQUOTES, 'UTF-8');
$im = imagecreatetruecolor(800, 600);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// $font = "/usr/share/fonts/corefonts/arial.ttf";
$font = "/usr/share/fonts/ttf-bitstream-vera/Vera.ttf";
$title_size = 42;
imagefilledrectangle($im, 0, 0, 800, 600, $black);
$this->_string_centered($im, 70, $title_size, $font, $white, $title);
header("Content-Type: image/png");
imagepng($im);
>>
>> Thus, it leads me back to my previous guess that the font he chose
>> (georgia.ttf) doesn't have Swedish characters in the set. With that,
>> I'm not sure, though, because I don't have the Georgia font pack on
>> here, so it'll have to stay as a guess for now.
>
> Georgia.tff should cover swedish characters - atleast it does on my
> system (MPB) ... my little test script in my other post on this thread
> works for me ... I have no idea if one should/could expect variations
> of supported characters in a TTF font file depending on the system your
> on (my guess would be you could rely on all systems that have said TTF
> file
> to support the same chars - I assume that although it may be compiled
> diffferently
> for different platforms the source font definition is going to be the
> same)
>
All fonts I have tried works in other applications with utf-8. (I run
lamp on my own workstation at the moment).
If anyone want to see the site or complete source I could send the url
off-list.
//*David Sveningsson [eXt]*
Freelance coder | Game Development Student
http://sidvind.com
Thou shalt make thy program's purpose and structure clear to thy fellow
man by using the One True Brace Style, even if thou likest it not, for
thy creativity is better used in solving problems than in creating
beautiful new impediments to understanding.
attached mail follows:
Jochem Maas skrev:
> Jochem Maas schreef:
>> have you tried a test script (file encoded as UTF8) where you
>> hardcode the
>> title string and see if that also outputs 'squares' ... at least that
>> way
>> you can be sure whether the problem is in some kind of encoding mush
>> that occurs
>> during the title's roundtrip of server -> browser -> server OR
>> whether the problem is
>> actually to do with imagetfftext.
>
> I tried in on my local machine (php5.2.5) and I can output swedish
> characters
> no problem (I hope the below test script comes through with borking the
> UTF-8 chars)
>
> <?php
>
> set_time_limit(0);
>
> //$title = html_entity_decode($_GET['title'], ENT_COMPAT, 'UTF-8');
> //$title = 'åååååååå bork';
> //$title = 'Pippi Långstrump går om bord';
> /*
> $title = 'Alla människor är födda fria
> och lika i värde och rättigheter.
> De är utrustade med förnuft och
> samvete och bör handla gentemot
> varandra i en anda av broderskap.';
> //*/
> $title = 'hå kå Å å Ä ä Ö ö å ö';
>
> ///
note Hardcoded resolution
> $im = imagecreatetruecolor(400, 200);
> $black = imagecolorallocate($im, 0, 0, 0);
> $white = imagecolorallocate($im, 255, 255, 255);
> //$font = "/Applications/OpenOffice.org
> 2.3.app/Contents/share/fonts/truetype/Georgia.ttf";
> $font = "/Library/Fonts/Georgia.ttf";
>
> $title_size = 18;
>
> imagefilledrectangle($im, 0, 0, 800, 600, $black);
>
> imagettftext( $im, $title_size, 0, 20, 40, $white, $font, $title );
>
> header("Content-Type: image/png");
> imagepng($im);
> exit();
It does sadly not work:
*Warning*: imagettftext() [function.imagettftext
<http://83.209.20.148/function.imagettftext>]: any2eucjp(): invalid code
in input string in
*/home/ext/workspace/code/trunk/Projects/Slideshow/frontend/public/foo.php*
on line *30
*If I suppress the warning I get an image with squares and random
letters. Is something wrong with my php installation?
linux-2.6.24-gentoo
PHP 5.2.5-p20080206-pl3-gentoo
Apache/2.2.8
'./configure' '--prefix=/usr/lib64/php5' '--host=x86_64-pc-linux-gnu'
'--mandir=/usr/lib64/php5/man' '--infodir=/usr/lib64/php5/info'
'--sysconfdir=/etc' '--cache-file=./config.cache' '--with-libdir=lib64'
'--enable-maintainer-zts' '--disable-cli' '--with-apxs2=/usr/sbin/apxs2'
'--with-config-file-path=/etc/php/apache2-php5'
'--with-config-file-scan-dir=/etc/php/apache2-php5/ext-active'
'--without-pear' '--enable-bcmath' '--with-bz2' '--enable-calendar'
'--with-curl' '--with-curlwrappers' '--disable-dbase' '--enable-exif'
'--without-fbsql' '--without-fdftk' '--enable-ftp' '--with-gettext'
'--with-gmp' '--with-kerberos=/usr' '--enable-mbstring' '--with-mcrypt'
'--with-mhash' '--without-msql' '--without-mssql' '--with-ncurses'
'--with-openssl' '--with-openssl-dir=/usr' '--enable-pcntl'
'--without-pgsql' '--with-pspell' '--without-recode' '--disable-shmop'
'--with-snmp' '--enable-soap' '--enable-sockets' '--without-sybase'
'--without-sybase-ct' '--enable-sysvmsg' '--enable-sysvsem'
'--enable-sysvshm' '--with-tidy' '--disable-wddx' '--with-xmlrpc'
'--with-xsl' '--enable-zip' '--with-zlib' '--disable-debug'
'--enable-dba' '--with-cdb' '--with-db4' '--with-flatfile' '--with-gdbm'
'--with-inifile' '--without-qdbm' '--with-freetype-dir=/usr'
'--with-t1lib=/usr' '--enable-gd-jis-conv' '--with-jpeg-dir=/usr'
'--with-png-dir=/usr' '--with-xpm-dir=/usr' '--with-gd' '--with-imap'
'--with-imap-ssl' '--with-ldap' '--without-ldap-sasl'
'--with-mysql=/usr' '--with-mysql-sock=/var/run/mysqld/mysqld.sock'
'--without-mysqli' '--with-unixODBC=/usr' '--without-adabas'
'--without-birdstep' '--without-dbmaker' '--without-empress'
'--without-esoob' '--without-ibm-db2' '--without-iodbc'
'--without-sapdb' '--without-solid' '--without-pdo-dblib'
'--with-pdo-mysql=/usr' '--with-pdo-odbc=unixODBC,/usr'
'--without-pdo-pgsql' '--with-pdo-sqlite=/usr' '--without-readline'
'--with-libedit' '--without-mm' '--with-sqlite=/usr' '--enable-sqlite-utf8'
attached mail follows:
Daniel Brown schreef:
> On Thu, Feb 28, 2008 at 5:06 AM, Jochem Maas <jochem
iamjochem.com> wrote:
>> Daniel Brown schreef:
>>> On Wed, Feb 27, 2008 at 1:56 PM, Richard S. Crawford
>> > <rscrawford
mossroot.com> wrote:
>> > [snip!]
>> >> I know that I could pass the name of the function as a parameter to the
>> >> error() function (e.g. error("bad_function","This is dumb")) but I'd rather
>> >> keep it simpler than that.
>> >>
>> >> Is there a way to do this?
>> >
>> > Not without a lower-level stack trace utility like xdebug, as far
>>
>> huh? what about debug_backtrace() ... contains plenty of info, including
>> function names of everything in the stack. of course something like xdebug
>> can take it to a whole new level.
>
> You're right. Forgot about that function. :-\
your forgiven, you've probably had a lot on your mind lately what with choosing a
dress for the ceremony :-P
>
attached mail follows:
On Fri, Feb 29, 2008 at 7:44 AM, Jochem Maas <jochem
iamjochem.com> wrote:
> Daniel Brown schreef:
> > On Thu, Feb 28, 2008 at 5:06 AM, Jochem Maas <jochem
iamjochem.com> wrote:
> >> huh? what about debug_backtrace() ... contains plenty of info, including
> >> function names of everything in the stack. of course something like xdebug
> >> can take it to a whole new level.
> >
> > You're right. Forgot about that function. :-\
>
> your forgiven, you've probably had a lot on your mind lately what with choosing a
> dress for the ceremony :-P
Oh, did I forget to mention that it's an open bar for everyone
*except* you, and that you'll be paying a mere seven-times the price
of normal drinks, with a 10 drink required minimum? ;-P
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Zoltán Németh wrote:
> 2008. 02. 28, csütörtök keltezéssel 10.38-kor Nathan Nobbe ezt Ãrta:
>> On Thu, Feb 28, 2008 at 10:35 AM, David Giragosian <dgiragosian
gmail.com>
>> wrote:
>>
>>> On 2/28/08, Nathan Nobbe <quickshiftin
gmail.com> wrote:
>>>> take a look here on the marc archives.
>>>> http://marc.info/?l=php-general&m=120415418217911&w=2
>>>>
>>>> there are several lines that have 1 word only in them, some of the words
>>>> (for reference) are access, good, patterns, nested.
>>>> when i wrote the post (looking in my gmail client) these words are not
>>> on
>>>> their own line..
>>>> does the post look as it does on marc in your mail clients or are the
>>> words
>>>> in sentences where they belong ?
>>>>
>>>> thanks,
>>>>
>>>> -nathan
>>>>
>>> Your emails come through to my gmail account as you first described,
>>> Nathan, ie, sometimes with just one word on a line, and just like the
>>> marc archives.
>>
>> thanks, ill just have to be careful editing from gmail then..
>>
>> Ray, if I start a thread, I'm fairly sure the list sends the email back to
>>> me.
>>
>> i dont get an email back until someone replies.
>
> that must be a gmail thing, I get everything back
>
> greets,
> Zoltán Németh
>
>> -nathan
>
>
Yeah, it is a gmail thing. They archive the message you send, so if you
were using the gmail client, you'd see your response. The FAQs say that
it'll send your message through IMAP/POP if someone replies to your
message, but gmail doesn't do nested threads, so I think it doesn't know
all the time when you were replied to.
--
Ray Hauge
www.primateapplications.com
attached mail follows:
On Fri, Feb 29, 2008 at 8:43 AM, Ray Hauge <ray.hauge.lists
gmail.com> wrote:
> Yeah, it is a gmail thing. They archive the message you send, so if you
> were using the gmail client, you'd see your response. The FAQs say that
> it'll send your message through IMAP/POP if someone replies to your
> message, but gmail doesn't do nested threads, so I think it doesn't know
> all the time when you were replied to.
You're 100% correct, Ray.
I use Gmail's web interface (to which I believe Ray is referring
as "the gmail client"), and when I send a message to a list, single
person, or anything, the message will show up in my sent box, but not
my inbox. This is completely expected behavior for any client.
However, as soon as I receive a response, my initiating message will
display as the first message in the thread, as well as in the sent
box.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
On Thu, Feb 28, 2008 at 11:03 PM, Jeff <akaman
akaproz.com> wrote:
> Please, can anyone tell me how to produce colored text? For instance if I
> wanted to following code to be printed as red text what would I need to add
> to they code? Thanks in advance.
>
> echo
> "<TR><TD>".$myrow["char_name"]."<TD>".$myrow["char_level"]."<TD>".$class["class"]."<TD>".$myrow["kara"]."<TD>".$myrow["karateam"]."<TD>".$myrow["karasub"];
Either CSS styling or the dreaded HTML "<font color=\"#FF0000\"
/>".$myrow['char_name']."</font>" tags.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
>> echo
>> "<TR><TD>".$myrow["char_name"]."<TD>".$myrow["char_level"]."<TD>".$class["class"]."<TD>".$myrow["kara"]."<TD>".$myrow["karateam"]."<TD>".$myrow["karasub"];
>
> Either CSS styling or the dreaded HTML "<font color=\"#FF0000\"
> />".$myrow['char_name']."</font>" tags.
>
But you should use CSS:
echo '<tr><td style="color: red">' ...
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
attached mail follows:
On Feb 29, 2008, at 10:07 AM, Richard Heyes wrote:
>>> echo
>>> "<TR><TD>".$myrow["char_name"]."<TD>".$myrow["char_level"]."<TD>".
>>> $class["class"]."<TD>".$myrow["kara"]."<TD>".
>>> $myrow["karateam"]."<TD>".$myrow["karasub"];
>> Either CSS styling or the dreaded HTML "<font color=\"#FF0000\"
>> />".$myrow['char_name']."</font>" tags.
>
> But you should use CSS:
>
> echo '<tr><td style="color: red">' ...
But if you're going to use CSS.. it would be better for managing it to
do it as a style sheet:
<style>
.red {
color: red;
}
</style>
echo '<tr><td class="red">';
Just my opinion :)
>
>
> --
> Richard Heyes
> Employ me:
> http://www.phpguru.org/cv
>
> --
> 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:
On Fri, Feb 29, 2008 at 10:21 AM, Jason Pruim <japruim
raoset.com> wrote:
>
> On Feb 29, 2008, at 10:07 AM, Richard Heyes wrote:
>
> >>> echo
> >>> "<TR><TD>".$myrow["char_name"]."<TD>".$myrow["char_level"]."<TD>".
> >>> $class["class"]."<TD>".$myrow["kara"]."<TD>".
> >>> $myrow["karateam"]."<TD>".$myrow["karasub"];
> >> Either CSS styling or the dreaded HTML "<font color=\"#FF0000\"
> >> />".$myrow['char_name']."</font>" tags.
> >
> > But you should use CSS:
> >
> > echo '<tr><td style="color: red">' ...
>
> But if you're going to use CSS.. it would be better for managing it to
> do it as a style sheet:
>
> <style>
> .red {
> color: red;
> }
> </style>
>
> echo '<tr><td class="red">';
>
> Just my opinion :)
Let's just get all purist and go back to the class="highlight" so we
don't find ourselves a year later with a stylesheet that includes
.red {
color: green;
}
:-) OK, so it's Friday.
Andrew
attached mail follows:
On Fri, Feb 29, 2008 at 10:29 AM, Andrew Ballard <aballard
gmail.com> wrote:
> On Fri, Feb 29, 2008 at 10:21 AM, Jason Pruim <japruim
raoset.com> wrote:
> > <style>
> > .red {
> > color: red;
> > }
> > </style>
>
> Let's just get all purist and go back to the class="highlight" so we
> don't find ourselves a year later with a stylesheet that includes
>
> .red {
> color: green;
> }
Andrew makes a good point, Jason. Despite the fact that it's just
a reference, it's easier to make a general reference to "highlight"
that can later be changed to weird colors like shale, aquamarine,
coffee, and taupe, than to have a style called "red" and have a future
designer look at the source and say, "damn, that Jason Pruim guy
doesn't know his .red from a #804000 in the ground.
> :-) OK, so it's Friday.
Indeed it is. ;-P
TFGIF and Happy Leap Day!
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
On Feb 29, 2008, at 10:44 AM, Daniel Brown wrote:
> On Fri, Feb 29, 2008 at 10:29 AM, Andrew Ballard
> <aballard
gmail.com> wrote:
>> On Fri, Feb 29, 2008 at 10:21 AM, Jason Pruim <japruim
raoset.com>
>> wrote:
>>> <style>
>>> .red {
>>> color: red;
>>> }
>>> </style>
>>
>> Let's just get all purist and go back to the class="highlight" so we
>> don't find ourselves a year later with a stylesheet that includes
>>
>> .red {
>> color: green;
>> }
>
> Andrew makes a good point, Jason. Despite the fact that it's just
> a reference, it's easier to make a general reference to "highlight"
> that can later be changed to weird colors like shale, aquamarine,
> coffee, and taupe, than to have a style called "red" and have a future
> designer look at the source and say, "damn, that Jason Pruim guy
> doesn't know his .red from a #804000 in the ground.
So I typed quickly on a friday without thinking it completely
through :P I've been doing more programming rather then designing
lately...
>
>
>> :-) OK, so it's Friday.
>
> Indeed it is. ;-P
>
> TFGIF and Happy Leap Day!
Yes it is!! I could not be more ready for the weekend :)
>
>
> --
> </Dan>
>
> Daniel P. Brown
> Senior Unix Geek
> <? while(1) { $me = $mind--; sleep(86400); } ?>
>
> --
> 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:
At 8:52 AM +0100 2/29/08, Zoltán Németh wrote:
>it's not just that, it's also a different way of thinking about your
>data. for example say you have a 'user' - you always have one of that ;)
>in procedural code you would store the properties of the user in an
>array or whatever, and have an include file with functions to manipulate
>the user. so why not group those two together in a class?
>
><very simplifying example>
>
>procedural code:
>include('user_functions.php');
>$user = load_user_data($userid);
>$user = set_user_name($user, 'tedd');
>
>oop code:
>include('user.class.php');
>$user = new User($userid);
>$user->setName('tedd');
>
></very simplifying example>
>
>see, same number of lines, so no added complexity. however the second
>one has some advantages:
>- you don't have to pass around the data since it is grouped together
>with the method you call
>- you don't have to worry about some ignorant developer calling
>set_user_name with, say, a product array - User->setName will always be
>called on a user object
>- the second one looks soo better ;) (ok, you said, new paint :) )
I can understand your oop code very well -- but
your procedural code example is lacking.
First, if I were to have information tied to a
user, then I would use MySQL and establish a
record with all the fields I needed for that
user. My code simply would be:
include('user_functions.php');
$user = set_user_name($user, 'tedd');
And thus, two lines instead of three.
But in fairness, the user_functions.php would
establish a connection to the database and the
function "set_user_name($user, 'tedd')" would
simply use 'tedd' with respect to whatever
"$user" is.
The number of lines of code really doesn't apply
with respect to organization value -- after all,
the best organization is to document your code
which certainly adds lines of "code". Sure, one
can argue that remarks are not code, but code
without them would be different, so in my mind
it's all code.
I don't think that you can show me an oop example
that I can't duplicate procedurally and that's my
point. Oop provides a different organization
method.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
2008. 02. 29, péntek keltezéssel 10.12-kor tedd ezt Ãrta:
> At 8:52 AM +0100 2/29/08, Zoltán Németh wrote:
> >it's not just that, it's also a different way of thinking about your
> >data. for example say you have a 'user' - you always have one of that ;)
> >in procedural code you would store the properties of the user in an
> >array or whatever, and have an include file with functions to manipulate
> >the user. so why not group those two together in a class?
> >
> ><very simplifying example>
> >
> >procedural code:
> >include('user_functions.php');
> >$user = load_user_data($userid);
> >$user = set_user_name($user, 'tedd');
> >
> >oop code:
> >include('user.class.php');
> >$user = new User($userid);
> >$user->setName('tedd');
> >
> ></very simplifying example>
> >
> >see, same number of lines, so no added complexity. however the second
> >one has some advantages:
> >- you don't have to pass around the data since it is grouped together
> >with the method you call
> >- you don't have to worry about some ignorant developer calling
> >set_user_name with, say, a product array - User->setName will always be
> >called on a user object
> >- the second one looks soo better ;) (ok, you said, new paint :) )
>
> I can understand your oop code very well -- but
> your procedural code example is lacking.
>
> First, if I were to have information tied to a
> user, then I would use MySQL and establish a
> record with all the fields I needed for that
> user. My code simply would be:
> include('user_functions.php');
> $user = set_user_name($user, 'tedd');
>
sure, all information belonging to an object is usually in a record of a
db.
but, you mean include('user_functions.php') automatically loads that
data? based on what? a global $user_id variable? if so, I would consider
that poor design...
> And thus, two lines instead of three.
>
> But in fairness, the user_functions.php would
> establish a connection to the database and the
> function "set_user_name($user, 'tedd')" would
> simply use 'tedd' with respect to whatever
> "$user" is.
hmm that means you use only one user's info in the script. that's very
limiting.
>
> The number of lines of code really doesn't apply
> with respect to organization value -- after all,
> the best organization is to document your code
> which certainly adds lines of "code". Sure, one
> can argue that remarks are not code, but code
> without them would be different, so in my mind
> it's all code.
>
> I don't think that you can show me an oop example
> that I can't duplicate procedurally and that's my
> point. Oop provides a different organization
> method.
sure you can duplicate with procedural code anything my tons of classes
do... but above a certain project size it can easily become a
maintenance nightmare and an integration nightmare if there are more
than one developers. classes enforce some strict rules to everyone in
the team, so teamwork is much more efficient and the resulting codebase
is cleaner. I know from experience, as this project with the 400K lines
is a rewrite of the previous procedural version, which was developed and
maintained by a dozen of developers over the years, and it became such a
mess that none of us wants to touch it anymore...
greets,
Zoltán Németh
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
attached mail follows:
At 4:36 PM +0100 2/29/08, Zoltán Németh wrote:
>sure, all information belonging to an object is usually in a record of a
>db.
>but, you mean include('user_functions.php') automatically loads that
>data? based on what? a global $user_id variable? if so, I would consider
>that poor design...
Whoa there, you don't know what it's doing -- so
saying poor design is probably not a good call.
> > And thus, two lines instead of three.
>>
>> But in fairness, the user_functions.php would
>> establish a connection to the database and the
>> function "set_user_name($user, 'tedd')" would
>> simply use 'tedd' with respect to whatever
>> "$user" is.
>
>hmm that means you use only one user's info in the script. that's very
>limiting.
Again, you don't know what's being called.
No reason to be insulting. What I am calling
could be a pointer or an id to a record -- BOTH
-- of which are no more limited than calling a
class. What do you think languages are doing when
they call segments of memory for data or function
-- you think they pass ton's of variables or just
a pointer? So, there's nothing limited here about
what I'm doing. Think about it.
>sure you can duplicate with procedural code anything my tons of classes
>do... but above a certain project size it can easily become a
>maintenance nightmare and an integration nightmare if there are more
>than one developers. classes enforce some strict rules to everyone in
>the team, so teamwork is much more efficient and the resulting codebase
>is cleaner. I know from experience, as this project with the 400K lines
>is a rewrite of the previous procedural version, which was developed and
>maintained by a dozen of developers over the years, and it became such a
>mess that none of us wants to touch it anymore...
Again -- the difference here is organizational
style. Everything you can do in your classes I
can do in my functions. Plus, you can have just
the same amount of screw-ups as I can when you
introduce more than one programmer and his style
into the mix.
I don't like the tone here -- it appears that
because I'm not agreeing with you that my code is
limited or of poor design -- because let me
assure you it's not!
So, let's just drop this -- you have your way and I have mine.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
tedd schreef:
> At 4:36 PM +0100 2/29/08, Zoltán Németh wrote:
...
>
> I don't like the tone here -- it appears that because I'm not agreeing
> with you that my code is limited or of poor design -- because let me
> assure you it's not!
>
> So, let's just drop this -- you have your way and I have mine.
>
from somewhere high, make it go splosh! ;-)
> Cheers,
>
> tedd
>
attached mail follows:
2008. 02. 29, péntek keltezéssel 14.28-kor tedd ezt Ãrta:
> At 4:36 PM +0100 2/29/08, Zoltán Németh wrote:
> >sure, all information belonging to an object is usually in a record of a
> >db.
> >but, you mean include('user_functions.php') automatically loads that
> >data? based on what? a global $user_id variable? if so, I would consider
> >that poor design...
>
> Whoa there, you don't know what it's doing -- so
> saying poor design is probably not a good call.
>
> > > And thus, two lines instead of three.
> >>
> >> But in fairness, the user_functions.php would
> >> establish a connection to the database and the
> >> function "set_user_name($user, 'tedd')" would
> >> simply use 'tedd' with respect to whatever
> >> "$user" is.
> >
> >hmm that means you use only one user's info in the script. that's very
> >limiting.
>
> Again, you don't know what's being called.
>
> No reason to be insulting. What I am calling
> could be a pointer or an id to a record -- BOTH
> -- of which are no more limited than calling a
> class. What do you think languages are doing when
> they call segments of memory for data or function
> -- you think they pass ton's of variables or just
> a pointer? So, there's nothing limited here about
> what I'm doing. Think about it.
hey, no insult intended here... sorry if seemed so.
but, my point was exactly what you stated above. you say 'you don't know
what's being called' - that's the main problem I found with non-oop code
organization. with clearly defined classes every developer knows what he
calls without further explanation.
>
> >sure you can duplicate with procedural code anything my tons of classes
> >do... but above a certain project size it can easily become a
> >maintenance nightmare and an integration nightmare if there are more
> >than one developers. classes enforce some strict rules to everyone in
> >the team, so teamwork is much more efficient and the resulting codebase
> >is cleaner. I know from experience, as this project with the 400K lines
> >is a rewrite of the previous procedural version, which was developed and
> >maintained by a dozen of developers over the years, and it became such a
> >mess that none of us wants to touch it anymore...
>
> Again -- the difference here is organizational
> style. Everything you can do in your classes I
> can do in my functions. Plus, you can have just
> the same amount of screw-ups as I can when you
> introduce more than one programmer and his style
> into the mix.
>
> I don't like the tone here -- it appears that
> because I'm not agreeing with you that my code is
> limited or of poor design -- because let me
> assure you it's not!
>
> So, let's just drop this -- you have your way and I have mine.
again, sorry for the tone if it was wrong - might be because I'm not a
native english speaker, or maybe because this is one of the craziest
fridays ever, I don't know. for sure, I didn't mean it.
and yes, let's drop this, I see I can't convince you.
anyway, I'm not an oop zealot, I just find it so useful and I tried to
explain my view of it - with absolutely no offense intended - so, happy
coding for you with your style and me with mine :)
greets,
Zoltán Németh
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
attached mail follows:
Zoltán Németh wrote:
> 2008. 02. 29, péntek keltezéssel 14.28-kor tedd ezt Ãrta:
>> At 4:36 PM +0100 2/29/08, Zoltán Németh wrote:
>>> sure, all information belonging to an object is usually in a record of a
>>> db.
>>> but, you mean include('user_functions.php') automatically loads that
>>> data? based on what? a global $user_id variable? if so, I would consider
>>> that poor design...
>> Whoa there, you don't know what it's doing -- so
>> saying poor design is probably not a good call.
>>
>>> > And thus, two lines instead of three.
>>>> But in fairness, the user_functions.php would
>>>> establish a connection to the database and the
>>>> function "set_user_name($user, 'tedd')" would
>>>> simply use 'tedd' with respect to whatever
>>>> "$user" is.
>>> hmm that means you use only one user's info in the script. that's very
>>> limiting.
>> Again, you don't know what's being called.
>>
>> No reason to be insulting. What I am calling
>> could be a pointer or an id to a record -- BOTH
>> -- of which are no more limited than calling a
>> class. What do you think languages are doing when
>> they call segments of memory for data or function
>> -- you think they pass ton's of variables or just
>> a pointer? So, there's nothing limited here about
>> what I'm doing. Think about it.
>
>
> hey, no insult intended here... sorry if seemed so.
> but, my point was exactly what you stated above. you say 'you don't know
> what's being called' - that's the main problem I found with non-oop code
> organization. with clearly defined classes every developer knows what he
> calls without further explanation.
>
>>> sure you can duplicate with procedural code anything my tons of classes
>>> do... but above a certain project size it can easily become a
>>> maintenance nightmare and an integration nightmare if there are more
>>> than one developers. classes enforce some strict rules to everyone in
>>> the team, so teamwork is much more efficient and the resulting codebase
>>> is cleaner. I know from experience, as this project with the 400K lines
>>> is a rewrite of the previous procedural version, which was developed and
>>> maintained by a dozen of developers over the years, and it became such a
>>> mess that none of us wants to touch it anymore...
>> Again -- the difference here is organizational
>> style. Everything you can do in your classes I
>> can do in my functions. Plus, you can have just
>> the same amount of screw-ups as I can when you
>> introduce more than one programmer and his style
>> into the mix.
>>
>> I don't like the tone here -- it appears that
>> because I'm not agreeing with you that my code is
>> limited or of poor design -- because let me
>> assure you it's not!
>>
>> So, let's just drop this -- you have your way and I have mine.
>
> again, sorry for the tone if it was wrong - might be because I'm not a
> native english speaker, or maybe because this is one of the craziest
> fridays ever, I don't know. for sure, I didn't mean it.
>
> and yes, let's drop this, I see I can't convince you.
> anyway, I'm not an oop zealot, I just find it so useful and I tried to
> explain my view of it - with absolutely no offense intended - so, happy
> coding for you with your style and me with mine :)
>
> greets,
> Zoltán Németh
>
>> Cheers,
>>
>> tedd
>>
>> --
>> -------
>> http://sperling.com http://ancientstones.com http://earthstones.com
>>
>
Aww man, I was getting curious to see how nested this conversation would
get. Think of the children! :)
PS. Happy Friday!!!
PPS. I'm hopped up on caffeine so ignore any stupid remarks.
--
Ray Hauge
www.primateapplications.com
attached mail follows:
On 2/28/08, Casey <heavyccasey
gmail.com> wrote:
> #!/usr/bin/php
Or the entirely more portable version:
#!/usr/bin/env php
<?php
--
Greg Donald
http://destiney.com/
attached mail follows:
Greg Donald schreef:
> On 2/28/08, Casey <heavyccasey
gmail.com> wrote:
>> #!/usr/bin/php
>
> Or the entirely more portable version:
>
> #!/usr/bin/env php
> <?php
thanks for the tip :-)
>
attached mail follows:
On Fri, 2008-02-29 at 05:17 -0500, Andrés Robinet wrote:
> > -----Original Message-----
> > From: Dani Castaños [mailto:danitao.mailists
gmail.com]
> > Sent: Friday, February 29, 2008 5:03 AM
> > To: PHP LIST
> > Subject: [PHP] Get country from Phone number
> >
> > Hi all!
> >
> > I'm looking for some piece of code or class which giving a phone number
> > it returns me from wich country is this phone.
> > Do you know where I can find something like this?
> >
> > Thank you in advanced!
> >
> > --
>
> Seems like you'll have a hard time if you want to include all the possibilities:
> http://www.kropla.com/dialcode.htm
> But probably Rob (Cummings) will come up with a "solve-it-all" regex that will
> save your day.
Regex is powerful, but I have my doubts it'll work in this case. If the
phone numbers are in standardized international format then it should be
a bit easier. Then you'll need a mapping of country codes to country.
Finally you'll need to be able to match variables length country codes
to the lookup map. I'm not sure, but it may be possible to determine the
largest possible country code and then use that as a first substring
attempt lookups into the mapping array. Then loop through the mapping
array and find the first country that has a prefix of the country code.
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. |
`------------------------------------------------------------'
attached mail follows:
On Fri, Feb 29, 2008 at 5:02 AM, Dani Castaños
<danitao.mailists
gmail.com> wrote:
> Hi all!
>
> I'm looking for some piece of code or class which giving a phone number
> it returns me from wich country is this phone.
> Do you know where I can find something like this?
Most likely you'll need a database, because you'll have to store
all area codes, as well. It's not enough to go by Country Code unless
you just want the continent to which the number terminates.
For example, I live in Pennsylvania (USA), and my country code is
1, my area code is 570 (and my exchange is 362, but that's getting
municipal). If I want to call Enterprise Network Consulting in
Whitehorse, Yukon, Canada, the country code is still 1, the area code
is 867 (and the local exchange is 668). Both numbers are 11-digits in
length, including the country code, yet terminate in different
countries entirely, and are over 3,500 miles (>5600 kilometers) apart.
So unless you wanted to split by continental region (e.g. - North
America), then you'll need a database. Aside from that, the
programming itself would be a piece of cake.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Dani Castaños wrote:
> Hi all!
>
> I'm looking for some piece of code or class which giving a phone number
> it returns me from wich country is this phone.
> Do you know where I can find something like this?
>
> Thank you in advanced!
>
As a little project, I took the link provided by "the other" Rob and make this
little search tool.
It only looks at the beginning numbers. It does no number validation. I don't
validate the length of the number. ie: I would have to know the min/max lenth
of each phone number for that given country/region, and I didn't search for that
information.
Let me know what you'll think.
http://www.cmsws.com/examples/php/areacodes/countrycodes.php
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
attached mail follows:
On Fri, Feb 29, 2008 at 5:22 AM, Shelley <myphplist
gmail.com> wrote:
> Hi all,
>
> What's the command to use if I want to remove all the directories and
> files except 'a.gz' under a directory?
There isn't a "command" in PHP to do this. You'd have to write a
script to handle that processing.
If you're looking for general Unix/Linux commands, you're in the
wrong place, but here's one possible way to do it:
sudo chattr +i /path/to/a.gz
rm -fR /path
sudo chattr -i /path/to/a.gz
If you have sudo access (or straight root access, in which case
you can su - to root and skip the 'sudo' part of the command), that
will set the file attribute to immutable, which means no one -
including root or the system itself - can modify or delete that file
unless they have the CAP_LINUX_IMMUTABLE capability (such as root) and
issue the 'chattr -i filename' command.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
On Thu, Feb 28, 2008 at 9:58 PM, Richard S. Crawford
<rscrawford
mossroot.com> wrote:
> I'm trying to figure out a way to make sure an included PHP file has no syntax
> errors before actually including it as a part of project. Is this even
> possible? I'm running into brick walls.
As far as I know, the only way to do that is via the CLI (or
accessing the include file directly in the browser).
Make sure that error_reporting is enabled and that it's set to
report E_ALL if you want to really be sure your code is clean (i.e. -
reporting unused, undefined, and uninstantiated variables, et cetera).
Then, if done from a *nix command line, just type:
php -l /path/to/include/file.php
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
De: Daniel Brown [mailto:parasane
gmail.com]
On Thu, Feb 28, 2008 at 9:58 PM, Richard S. Crawford
<rscrawford
mossroot.com> wrote:
> I'm trying to figure out a way to make sure an included PHP file has
> no syntax errors before actually including it as a part of project.
> Is this even possible? I'm running into brick walls.
As far as I know, the only way to do that is via the CLI
(or accessing the include file directly in the browser).
Make sure that error_reporting is enabled and that it's set
to report E_ALL if you want to really be sure your code is
clean (i.e. - reporting unused, undefined, and uninstantiated
variables, et cetera).
Then, if done from a *nix command line, just type:
php -l /path/to/include/file.php
--
</Dan>
--**--
Just being curious and lazy. The description of php -l in php.net says it
executes the script to check it's syntax.
Ok, but... It _executes_ the script as if I ran it directly? or just
_checks_ it's syntax?
There's a big difference in there.
--
PHP General Mailing List (http://www.php.net/) To unsubscribe,
visit: http://www.php.net/unsub.php
attached mail follows:
Thanks to everyone for the suggestions. Unfortunately, I'm up against a
couple of major hurdles:
1. My host does not allow command line access and has disabled shell
execution of PHP;
2. Error reporting has been turned off and I can't seem to turn that on
with ini_set or error_reporting (which is fun when I have minor syntax
errors to fix); and
3. My host is also stuck in PHP 4.3, so the check_syntax function isn't
available to me either (although I understand that this function has been
deprecated in the most recent builds of PHP).
At this point, I'll just use file_exists and is_readable for some basic
checking, and hope that the included files have no syntax errors.
On Fri, Feb 29, 2008 at 11:25 AM, Daniel Brown <parasane
gmail.com> wrote:
> On Thu, Feb 28, 2008 at 9:58 PM, Richard S. Crawford
> <rscrawford
mossroot.com> wrote:
> > I'm trying to figure out a way to make sure an included PHP file has no
> syntax
> > errors before actually including it as a part of project. Is this even
> > possible? I'm running into brick walls.
>
> As far as I know, the only way to do that is via the CLI (or
> accessing the include file directly in the browser).
>
> Make sure that error_reporting is enabled and that it's set to
> report E_ALL if you want to really be sure your code is clean (i.e. -
> reporting unused, undefined, and uninstantiated variables, et cetera).
>
> Then, if done from a *nix command line, just type:
> php -l /path/to/include/file.php
>
> --
> </Dan>
>
> Daniel P. Brown
> Senior Unix Geek
> <? while(1) { $me = $mind--; sleep(86400); } ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Richard S. Crawford (rscrawford
mossroot.com)
http://www.mossroot.com
Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
Support me in Write-a-thon 2007:
http://www.firstgiving.com/richardscrawford
attached mail follows:
> 1. My host does not allow command line access and has disabled shell
> execution of PHP;
>
> 2. Error reporting has been turned off and I can't seem to turn that on
> with ini_set or error_reporting (which is fun when I have minor syntax
> errors to fix); and
>
> 3. My host is also stuck in PHP 4.3, so the check_syntax function isn't
> available to me either (although I understand that this function has been
> deprecated in the most recent builds of PHP).
To be quite honest, your host sounds like it sucks donkey dick. Get
another if you can.
> At this point, I'll just use file_exists and is_readable for some basic
> checking, and hope that the included files have no syntax errors.
Hoping something works leads you down the path of severely broken code.
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
attached mail follows:
On Fri, Feb 29, 2008 at 2:32 PM, Richard S. Crawford
<rscrawford
mossroot.com> wrote:
> Thanks to everyone for the suggestions. Unfortunately, I'm up against a
> couple of major hurdles:
Not to be a smartass with my responses here....
> 1. My host does not allow command line access and has disabled shell execution of PHP;
Get a new host that will allow commands and offers access to
people who know how to correctly use it.
> 2. Error reporting has been turned off and I can't seem to turn that on
> with ini_set or error_reporting (which is fun when I have minor syntax
> errors to fix); and
Get a new host that understands that - while they may want to hide
their own errors - disabling error_reporting for all customer websites
by default is asinine.
> 3. My host is also stuck in PHP 4.3, so the check_syntax function isn't
> available to me either (although I understand that this function has been
> deprecated in the most recent builds of PHP).
Get a new host that knows how to administer a web server. PHP 4.3
was released 27 December, 2002, with the latest from the 4.3 branch
(4.3.11) being released 31 March, 2005. The CHANGELOG should give you
an idea of how *horrible* this is: http://www.php.net/ChangeLog-4.php
All of PHP4 reached its EOL the last day of 2007, but at the very
least, try to find a host that uses a version of PHP newer than three
to five years old.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Richard S. Crawford schreef:
> Thanks to everyone for the suggestions. Unfortunately, I'm up against a
> couple of major hurdles:
>
> 1. My host does not allow command line access and has disabled shell
> execution of PHP;
>
> 2. Error reporting has been turned off and I can't seem to turn that on
> with ini_set or error_reporting (which is fun when I have minor syntax
> errors to fix); and
which ini setting? if you want to see your errors in the browser you need
display_errors set to On. error_reporting only sets the level of reporting.
>
> 3. My host is also stuck in PHP 4.3, so the check_syntax function isn't
> available to me either (although I understand that this function has been
> deprecated in the most recent builds of PHP).
make your host your ex-host.
> At this point, I'll just use file_exists and is_readable for some basic
> checking, and hope that the included files have no syntax errors.
it seems madness that you don't seem to test code before incorporating it
into a production system. at the very least anything you put on a website should
parse properly.
have you considered installing a local copy of php (and suitable webserver)
so you can test it there?
>
> On Fri, Feb 29, 2008 at 11:25 AM, Daniel Brown <parasane
gmail.com> wrote:
>
>> On Thu, Feb 28, 2008 at 9:58 PM, Richard S. Crawford
>> <rscrawford
mossroot.com> wrote:
>>> I'm trying to figure out a way to make sure an included PHP file has no
>> syntax
>>> errors before actually including it as a part of project. Is this even
>>> possible? I'm running into brick walls.
>> As far as I know, the only way to do that is via the CLI (or
>> accessing the include file directly in the browser).
>>
>> Make sure that error_reporting is enabled and that it's set to
>> report E_ALL if you want to really be sure your code is clean (i.e. -
>> reporting unused, undefined, and uninstantiated variables, et cetera).
>>
>> Then, if done from a *nix command line, just type:
>> php -l /path/to/include/file.php
>>
>> --
>> </Dan>
>>
>> Daniel P. Brown
>> Senior Unix Geek
>> <? while(1) { $me = $mind--; sleep(86400); } ?>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
attached mail follows:
On Fri, Feb 29, 2008 at 3:42 PM, Jochem Maas <jochem
iamjochem.com> wrote:
> have you considered installing a local copy of php (and suitable webserver)
> so you can test it there?
Always good advice. At the very least, a remote dev box on which
to work the code. However, it's not going to be the Holy Grail (as I
know Jochem's already aware, but I'll point out for newbies), because
it's more work than is generally justifiable to mirror an entire
server's environment for a single project. For example, why would you
want to limit yourself to such antiquated technology on your
development box (losing a lot of functionality, and re-creating
security vulnerabilities and system problems) just to match to a bad
web host?
More common, you may install Apache 2.0.48 with PHP as an ASPX2
module with the GD library, which has distinct differences from an
Apache 1.3.37 with PHP as CGI with bundled GD.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Nathan Rixham wrote:
> Nathan Nobbe wrote:
>> On Thu, Feb 28, 2008 at 6:14 PM, Nathan Rixham <nrixham
gmail.com> wrote:
>>
>>> if I show you guys how to do this:
>>>
>>> echo sillyFunc()['a'] . PHP_EOL;
>>>
>>> using a few brackets and things do you promise not to laugh?
>>> *it's a bit weird*
>>
>>
>> id like to see it.
>>
>> -nathan
>>
>
> don't say I didn't warn ya fellow nathan!
>
> #!/usr/bin/php
> <?php
> function sillyFunc() {
> return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some
> string');
> }
>
> echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL;
>
> --- output ---
> some string
>
>
> To make things a little weirder yet here's the var's lol:
>
> print_r(get_defined_vars());
>
> [] => sillyFunc
> [¹] => Array
> (
> [a] => 1
> [b] => 2
> [c] => 3
> [d] => 4
> [e] => some string
> )
>
>
> to reference the var holding "string sillyFunc" (any of):
> echo ${''}; echo ${NULL}; echo ${FALSE};
>
> to reference our array [¹] (yeah it is called ¹)
> print_r(${~${''}});
>
>
> here's a quick simplification + alternatives.
>
> echo (!$array = sillyFunc()),$array['e'];
> echo (!$array = sillyFunc()).$array['e'];
>
> and a useful ternary one:
> echo is_array($array = sillyFunc()) ? $array['e'] : '';
>
>
> told you it was a bit weird [took me a couple hours to figure out]!
>
> nath :)
ROFLMAO, ha ha ha ha ha ha ha ha hoo ha ha ha ha ha hooo haaa!
attached mail follows:
Emiliano Boragina wrote:
> Hi list…
>
> All this in the same php:
>
>
>
> <?
>
> $folder = 'pictures;
>
> $load = copy($_FILES['file']['tmp_name'] , $folder . '/' . $_FILES
> ['file']['name']);
>
> if ( $load ) {
>
> echo "Picture upload!";
>
> } else {
>
> echo "no picture =(";
>
> }
>
> ?>
>
> <form action="" method="post" enctype="multipart/form-data">
>
> <input type="text" name="folder">
>
> <input type="submit" value="ADD FOLDER">
>
> <hr>
>
> <input type="file" name="file">
>
> <input type="submit" value="UPLOAD">
>
> </form>
>
>
>
> When I try the php the echo "no picture =("; is there. How can I do to don’t
> appears the message before I upload de picture.
>
> Thanks.
>
>
>
>
>
> + _
> // Emiliano Boragina _
>
> // Diseño & Comunicación //////////////////
> + _
>
> // emiliano.boragina
gmail.com /
> // 15 40 58 60 02 ///////////////////////////
> + _
>
>
>
>
if(!empty($_POST['file'])) {
//your php
}
-Shawn
attached mail follows:
On Thu, Feb 28, 2008 at 11:08 PM, Emiliano Boragina
<emiliano.boragina
gmail.com> wrote:
> When I try the php the echo "no picture =("; is there. How can I do to don't
> appears the message before I upload de picture.
Here's your code, re-written.
<?
if(isset($_FILES)) {
// The following regexp handles file extension checking. Modify
it as needed.
if(preg_match('/(.*)(bmp|gif|jpeg|jpg|png)$/i',substr(basename(__FILE__),-3,3)))
{
$folder = 'pictures';
if(copy($_FILES['file']['tmp_name'] , $folder . '/' .
$_FILES['file']['name']))
echo "Picture upload!";
} else {
echo "no picture =(";
}
} else {
// Handle your "incorrect file type" errors here.
die("Incorrect file type.");
}
}
?>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post"
enctype="multipart/form-data">
<!--
These fields are hidden. You can only have one submit button per form,
and we're only dealing with the image uploads with this question.
<input type="text" name="folder">
<input type="submit" value="ADD FOLDER">
<hr>
-->
<input type="file" name="file">
<input type="submit" value="UPLOAD">
</form>
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Daniel Brown wrote:
> On Thu, Feb 28, 2008 at 11:08 PM, Emiliano Boragina
> <emiliano.boragina
gmail.com> wrote:
>> When I try the php the echo "no picture =("; is there. How can I do to don't
>> appears the message before I upload de picture.
>
> Here's your code, re-written.
>
> <?
> if(isset($_FILES)) {
> // The following regexp handles file extension checking. Modify
> it as needed.
> if(preg_match('/(.*)(bmp|gif|jpeg|jpg|png)$/i',substr(basename(__FILE__),-3,3)))
> {
> $folder = 'pictures';
First, the op should use is_uploaded_file() to check and make sure that it is a
file that was infact uploaded.
http://us3.php.net/manual/en/function.is-uploaded-file.php
Secondly, the op should use move_uploaded_file() instead instead of copy.
http://us3.php.net/manual/en/function.move-uploaded-file.php
They were created for a reason
> if(copy($_FILES['file']['tmp_name'] , $folder . '/' .
> $_FILES['file']['name']))
> echo "Picture upload!";
> } else {
> echo "no picture =(";
> }
> } else {
> // Handle your "incorrect file type" errors here.
> die("Incorrect file type.");
> }
> }
> ?>
> <form action="<?=$_SERVER['PHP_SELF'];?>" method="post"
> enctype="multipart/form-data">
> <!--
> These fields are hidden. You can only have one submit button per form,
> and we're only dealing with the image uploads with this question.
At least in "HTML 4 Specification" you can have more then one submit button.
http://www.w3.org/TR/html4/interact/forms.html#submit-button
>
> <input type="text" name="folder">
> <input type="submit" value="ADD FOLDER">
> <hr>
> -->
> <input type="file" name="file">
> <input type="submit" value="UPLOAD">
> </form>
>
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
attached mail follows:
On Fri, Feb 29, 2008 at 3:30 PM, Jim Lucas <lists
cmsws.com> wrote:
> First, the op should use is_uploaded_file() to check and make sure that it is a
> file that was infact uploaded.
> http://us3.php.net/manual/en/function.is-uploaded-file.php
>
> Secondly, the op should use move_uploaded_file() instead instead of copy.
> http://us3.php.net/manual/en/function.move-uploaded-file.php
>
> They were created for a reason
You're right. I meant to change those in the psuedocode I sent