Re: [PHP] echo?
Are you sure? $ php -a php > for ($i = 0; $i < 10; $i++) { echo $i . ' '; } 0 1 2 3 4 5 6 7 8 9 David
Re: [PHP] echo?
On 11-03-22 06:22 PM, Jim Giner wrote: Kinda new to this, but I've been puttering/writing for about 3 weeks now and have some good working screens up. Ran into something new while I was debuggina script today. Tried to echo the $i value within a for loop as part of the list of items I was building Something like for ($i=0;$i<$rows;$i++) echo $i.' '.$row['itemname']; I expected to see : 1 item1 2 item2 ... ... but instead I got 1 item1 f item2 Yes - an 'f' and not a 2. Tried it some more with this: for ($i=1;$i<10;$i++) echo $i." item".''; and got c item d item e item f item g item and so on. It seems that I can only output the value of $i if I output a string in front of it echo ' '.$i; works fine but echo $i; does not. Any ideas? I'd like to see the actual code... since $row['itemname'] wouldn't change between iterations either. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo?
On Tue, Mar 22, 2011 at 18:22, Jim Giner wrote: [snip!] > > for ($i=0;$i<$rows;$i++) > echo $i.' '.$row['itemname']; > > I expected to see : > > 1 item1 > 2 item2 > ... > ... > > but instead I got > > 1 item1 > f item2 > > Yes - an 'f' and not a 2. > > Tried it some more with this: > > for ($i=1;$i<10;$i++) > echo $i." item".''; > > and got > > c item > d item > e item > f item > g item > > and so on. That sounds very odd. Can you show us the actual surrounding code, Jim? -- Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo?
Kinda new to this, but I've been puttering/writing for about 3 weeks now and have some good working screens up. Ran into something new while I was debuggina script today. Tried to echo the $i value within a for loop as part of the list of items I was building Something like for ($i=0;$i<$rows;$i++) echo $i.' '.$row['itemname']; I expected to see : 1 item1 2 item2 ... ... but instead I got 1 item1 f item2 Yes - an 'f' and not a 2. Tried it some more with this: for ($i=1;$i<10;$i++) echo $i." item".''; and got c item d item e item f item g item and so on. It seems that I can only output the value of $i if I output a string in front of it echo ' '.$i; works fine but echo $i; does not. Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Echo result in a loop on each instance
I have a question regarding echo of a var/string in a loop on each instance A shortened example: Lets say I have an array of values (rather big), and then I loop through this array: for or foreach : { $value = $arrValAll[$i]; echo "test".$i."--> ".$value; } When the script runs it will only start to echo values after certain period ... it does not echo immediately ... how can I force it start echo as soon as the first echo instance is done ? I thought ob_start does this but I have tried it and not getting what I want. Is there some other way/correct to do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo SESSION var doesn't work if unset after echo
On Tue, 2008-12-09 at 16:51 -0500, Eric Wood wrote: > I have two vars doing the same thing. One is echo'd/unset in the > section and the other echo'd/unset in the footer of the page. > No re-direct request is being made. > > Ok now check this. If I use this code: > > if(isset($_SESSION["Ecomm"])) { >echo $_SESSION["Ecomm"]; >unset($_SESSION["Ecomm"]); > } > > I can *NOT* see the Ecomm contents in the right-click -> View Page Source. > I do see the complete in the "View Generated Source". > > Now, If I comment out the unset: > > if(isset($_SESSION["Ecomm"])) { >echo $_SESSION["Ecomm"]; >// unset($_SESSION["Ecomm"]); > } > > Then I *CAN* see the Ecomm code in the in the right-click -> View Page > Source as well as the "View Generated Source". > > I am very humbled right now. > > -eric wood > > - Original Message - > From: <[EMAIL PROTECTED]> > > My theory is that the browser is RE-requesting the data because of the > > private, must-revalidate. > > > > So it goes like this: > > > > Browser -> GET -> Ecomm: fooie ; unset Ecomm > > Browser -> GET -> Ecomm: [not set] > > I don't think anyone mentioned a redirect request. Rather, to speed up loading of pages, browsers make simultaneous GET requests for the page. This is why forms should always use GET to retrieve data that will not change, and POST to change data or state. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo SESSION var doesn't work if unset after echo
I have two vars doing the same thing. One is echo'd/unset in the section and the other echo'd/unset in the footer of the page. No re-direct request is being made. Ok now check this. If I use this code: if(isset($_SESSION["Ecomm"])) { echo $_SESSION["Ecomm"]; unset($_SESSION["Ecomm"]); } I can *NOT* see the Ecomm contents in the right-click -> View Page Source. I do see the complete in the "View Generated Source". Now, If I comment out the unset: if(isset($_SESSION["Ecomm"])) { echo $_SESSION["Ecomm"]; // unset($_SESSION["Ecomm"]); } Then I *CAN* see the Ecomm code in the in the right-click -> View Page Source as well as the "View Generated Source". I am very humbled right now. -eric wood - Original Message - From: <[EMAIL PROTECTED]> My theory is that the browser is RE-requesting the data because of the private, must-revalidate. So it goes like this: Browser -> GET -> Ecomm: fooie ; unset Ecomm Browser -> GET -> Ecomm: [not set] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo SESSION var doesn't work if unset after echo
On Wed, Dec 10, 2008 at 8:11 AM, <[EMAIL PROTECTED]> wrote: > > Fire up Live HTTP Headers in Firefox. > Where is this "Live HTTP Headers in Firefox"? Is it an extension? > > My theory is that the browser is RE-requesting the data because of the > private, must-revalidate. > > So it goes like this: > > Browser -> GET -> Ecomm: fooie ; unset Ecomm > Browser -> GET -> Ecomm: [not set] > > If you are using Ajax and JS and whatnot, the probability of this being the > culprit increases. :-) > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] echo SESSION var doesn't work if unset after echo
On Tue, 2008-12-09 at 19:11 +, [EMAIL PROTECTED] wrote: > Fire up Live HTTP Headers in Firefox. > > > > My theory is that the browser is RE-requesting the data because of the > private, must-revalidate. > > > > So it goes like this: > > > > Browser -> GET -> Ecomm: fooie ; unset Ecomm > > Browser -> GET -> Ecomm: [not set] > > > > If you are using Ajax and JS and whatnot, the probability of this being the > culprit increases. :-) > > > If the php is executed because of a GET request, i.e. from a link, then the page could well be requested twice. I've seen this happen before, where I was adding entries to a database when a user navigated to a certain page from a link. The way I solved it was to add a timestamp and check to see if an exact duplicate entry had been made within the last n seconds before adding it. You could add a time value to the session and check against this before unsetting the session? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo SESSION var doesn't work if unset after echo
Fire up Live HTTP Headers in Firefox. My theory is that the browser is RE-requesting the data because of the private, must-revalidate. So it goes like this: Browser -> GET -> Ecomm: fooie ; unset Ecomm Browser -> GET -> Ecomm: [not set] If you are using Ajax and JS and whatnot, the probability of this being the culprit increases. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo SESSION var doesn't work if unset after echo
I set Ecomm to a little javascript code on the previous page then echo it no the next page. session_cache_limiter ('private, must-revalidate'); session_start(); . stuff ... if(isset($_SESSION["Ecomm"])) { echo $_SESSION["Ecomm"]; unset($_SESSION["Ecomm"]); } . stuff ... For some unknown reason echoing this particular session var is now blank and the page's source code proves that it is missing. Now when I comment out the unset statement, then the crazy thing works. I see the code in the page's source. It is as if php is doing this: if(isset($_SESSION["Ecomm"])) { unset($_SESSION["Ecomm"]); echo $_SESSION["Ecomm"]; } No kernel, apache, or php updates have happened. An there's not errors logged. Truely strange. Any ideas? -Eric Wood
Re: [PHP] Echo in __GET()
You can write 2 functions to handle this. Value and OutputValue Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Tyler C. wrote: > Is the a way to have an array, or use __get() to provide different > data if you are echoing a variable, rather than if you are using it in > a 'if' statement? > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Echo in __GET()
Is the a way to have an array, or use __get() to provide different data if you are echoing a variable, rather than if you are using it in a 'if' statement? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
Nice trick, I will remember this one. Thanks for sharing, Nitsan On 23/05/2008, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > > On Fri, Feb 29, 2008 at 12:16 AM, Nathan Nobbe <[EMAIL PROTECTED]> > wrote: > > > wow, im going to have to stare at some of those and play around with them > > as soon as im half awake :) > > > > of course i still like my solution ;) but im excited about the > > experimentation and ideas that have been shared on this topic, very > > interesting really! > > > i added __set() to my original class, now i can do cool stuff, like this: > >$a = ArrayClass::simpleFactory(getArray())->{'a'} = 5; > > which allows retrieval of the array, and modification (or access) to a > given > member, in a single statement. > > class ArrayClass { >private $theArray = array(); > >private function __construct($theArray) { >$this->theArray = $theArray; >} > >public static function simpleFactory($theArray) { >return new self($theArray); >} > >public function __get($member) { >if(array_key_exists($this->theArray, $member)) { >return $this->theArray[$member]; >} >return null; >} > >public function __set($member, $value) { >$this->theArray[$member] = $value; >} > } > > function getArray() { >return array( >'a' => 1, >'b' => 2 >); > } > > $a = ArrayClass::simpleFactory(getArray())->{'a'} = 5; > var_dump($a); > ?> > > maybe boring to some (or many :D) but as the first time around, i just > thought it was cool and id share. > > -nathan >
Re: [PHP] echo returnArray()['a']; // workaround
On Fri, Feb 29, 2008 at 12:16 AM, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > wow, im going to have to stare at some of those and play around with them > as soon as im half awake :) > > of course i still like my solution ;) but im excited about the > experimentation and ideas that have been shared on this topic, very > interesting really! i added __set() to my original class, now i can do cool stuff, like this: $a = ArrayClass::simpleFactory(getArray())->{'a'} = 5; which allows retrieval of the array, and modification (or access) to a given member, in a single statement. theArray = $theArray; } public static function simpleFactory($theArray) { return new self($theArray); } public function __get($member) { if(array_key_exists($this->theArray, $member)) { return $this->theArray[$member]; } return null; } public function __set($member, $value) { $this->theArray[$member] = $value; } } function getArray() { return array( 'a' => 1, 'b' => 2 ); } $a = ArrayClass::simpleFactory(getArray())->{'a'} = 5; var_dump($a); ?> maybe boring to some (or many :D) but as the first time around, i just thought it was cool and id share. -nathan
Re: [PHP] echo returnArray()['a']; // workaround
Nathan Rixham wrote: > Nathan Nobbe wrote: >> On Thu, Feb 28, 2008 at 6:14 PM, Nathan Rixham <[EMAIL PROTECTED]> 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 > 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! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
wow, im going to have to stare at some of those and play around with them as soon as im half awake :) of course i still like my solution ;) but im excited about the experimentation and ideas that have been shared on this topic, very interesting really! -nathan
Re: [PHP] echo returnArray()['a']; // workaround
On Fri, 2008-02-29 at 05:34 +, Nathan Rixham wrote: > Casey wrote: > > > > I don't know why I'm continuing this... but for the truly crazy: > > function w(&$t) { > > $t = array('f' => '...'); > > return 't'; > > } > > > > echo ${w($t)}['f']; > > > > addictive isn't it! > > casey, I truelly believe that's as short as it can get - and a great bit > of code reduction - most impressed :D > > concider: w()['f'] I'm sure you meant consider. Concider sounds like fake cider ;) > the only additions are a ${} wrapper! Doesn't work that way, he needs the reference in that last one. The last one is a pseudo solution since it requires the helper reference which gets littered in the calling scope. 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
Casey wrote: I don't know why I'm continuing this... but for the truly crazy: function w(&$t) { $t = array('f' => '...'); return 't'; } echo ${w($t)}['f']; addictive isn't it! casey, I truelly believe that's as short as it can get - and a great bit of code reduction - most impressed :D concider: w()['f'] the only additions are a ${} wrapper! nice -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, Feb 28, 2008 at 8:42 PM, Casey <[EMAIL PROTECTED]> wrote: > > On Thu, Feb 28, 2008 at 8:38 PM, Nathan Rixham <[EMAIL PROTECTED]> wrote: > > > > Robert Cummings wrote: > > > On Thu, 2008-02-28 at 23:27 -0500, Robert Cummings wrote: > > >> On Fri, 2008-02-29 at 04:04 +, Nathan Rixham wrote: > > >>> Robert Cummings wrote: > > On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: > > > don't say I didn't warn ya fellow nathan! > > > > > > #!/usr/bin/php > > > > > function sillyFunc() { > > > return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some > string'); > > > } > > > > > > echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; > > > > I was ready to use this system everywhere in my code until I saw > that it > > generates an E_STRICT... now I'll just have to keep with what I > usually > > do. > > > > Cheers, > > Rob. > > >>> scratch the former! > > >>> > > >>> FIXED>> > > >>> > > >>> echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; > > >> Ok, I lied... I'm not really gonna use it. Interesting tidbit of > > >> obfuscation though. > > > > > > BTW... the following is shorter: > > > > > > echo ${~${''}='sillyFunc'}['e'] . PHP_EOL; > > > > > > Cheers, > > > Rob. > > > > but doesn't work over here.. php 5.2.4 && 5 > > > > > > > Doesn't work for me either. Here's mine: > > function ReturnArray() { > return array('a' => 'f', 'b' => 'g', 'c' => 'h', 'd' => 'i', > 'e' => 'j'); > } > echo ${(${0}=ReturnArray())&0}['a']; > > -- > -Casey > By the way, this could be compressed simply to echo ${!${!1}=ReturnArray()}['a']; I don't know why I'm continuing this... but for the truly crazy: function w(&$t) { $t = array('f' => '...'); return 't'; } echo ${w($t)}['f']; -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, 2008-02-28 at 20:42 -0800, Casey wrote: > On Thu, Feb 28, 2008 at 8:38 PM, Nathan Rixham <[EMAIL PROTECTED]> wrote: > > > > Robert Cummings wrote: > > > On Thu, 2008-02-28 at 23:27 -0500, Robert Cummings wrote: > > >> On Fri, 2008-02-29 at 04:04 +, Nathan Rixham wrote: > > >>> Robert Cummings wrote: > > On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: > > > don't say I didn't warn ya fellow nathan! > > > > > > #!/usr/bin/php > > > > > function sillyFunc() { > > > return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some > > string'); > > > } > > > > > > echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; > > > > I was ready to use this system everywhere in my code until I saw that > > it > > generates an E_STRICT... now I'll just have to keep with what I > > usually > > do. > > > > Cheers, > > Rob. > > >>> scratch the former! > > >>> > > >>> FIXED>> > > >>> > > >>> echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; > > >> Ok, I lied... I'm not really gonna use it. Interesting tidbit of > > >> obfuscation though. > > > > > > BTW... the following is shorter: > > > > > > echo ${~${''}='sillyFunc'}['e'] . PHP_EOL; > > > > > > Cheers, > > > Rob. > > > > but doesn't work over here.. php 5.2.4 && 5 > > > > > > > Doesn't work for me either. Here's mine: > > function ReturnArray() { > return array('a' => 'f', 'b' => 'g', 'c' => 'h', 'd' => 'i', > 'e' => 'j'); > } > echo ${(${0}=ReturnArray())&0}['a']; That's definitely superior... you can even give parameters. 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, Feb 28, 2008 at 8:38 PM, Nathan Rixham <[EMAIL PROTECTED]> wrote: > > Robert Cummings wrote: > > On Thu, 2008-02-28 at 23:27 -0500, Robert Cummings wrote: > >> On Fri, 2008-02-29 at 04:04 +, Nathan Rixham wrote: > >>> Robert Cummings wrote: > On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: > > don't say I didn't warn ya fellow nathan! > > > > #!/usr/bin/php > > > function sillyFunc() { > > return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some > string'); > > } > > > > echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; > > I was ready to use this system everywhere in my code until I saw that it > generates an E_STRICT... now I'll just have to keep with what I usually > do. > > Cheers, > Rob. > >>> scratch the former! > >>> > >>> FIXED>> > >>> > >>> echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; > >> Ok, I lied... I'm not really gonna use it. Interesting tidbit of > >> obfuscation though. > > > > BTW... the following is shorter: > > > > echo ${~${''}='sillyFunc'}['e'] . PHP_EOL; > > > > Cheers, > > Rob. > > but doesn't work over here.. php 5.2.4 && 5 > > > Doesn't work for me either. Here's mine: function ReturnArray() { return array('a' => 'f', 'b' => 'g', 'c' => 'h', 'd' => 'i', 'e' => 'j'); } echo ${(${0}=ReturnArray())&0}['a']; -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Fri, 2008-02-29 at 04:38 +, Nathan Rixham wrote: > Robert Cummings wrote: > > On Thu, 2008-02-28 at 23:27 -0500, Robert Cummings wrote: > >> On Fri, 2008-02-29 at 04:04 +, Nathan Rixham wrote: > >>> Robert Cummings wrote: > On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: > > don't say I didn't warn ya fellow nathan! > > > > #!/usr/bin/php > > > function sillyFunc() { > > return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some > > string'); > > } > > > > echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; > > I was ready to use this system everywhere in my code until I saw that it > generates an E_STRICT... now I'll just have to keep with what I usually > do. > > Cheers, > Rob. > >>> scratch the former! > >>> > >>> FIXED>> > >>> > >>> echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; > >> Ok, I lied... I'm not really gonna use it. Interesting tidbit of > >> obfuscation though. > > > > BTW... the following is shorter: > > > > echo ${~${''}='sillyFunc'}['e'] . PHP_EOL; > > > > Cheers, > > Rob. > > but doesn't work over here.. php 5.2.4 && 5 Works in 4.4.8 and 5.2.5 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
Robert Cummings wrote: On Thu, 2008-02-28 at 23:27 -0500, Robert Cummings wrote: On Fri, 2008-02-29 at 04:04 +, Nathan Rixham wrote: Robert Cummings wrote: On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: don't say I didn't warn ya fellow nathan! #!/usr/bin/php 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some string'); } echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; I was ready to use this system everywhere in my code until I saw that it generates an E_STRICT... now I'll just have to keep with what I usually do. Cheers, Rob. scratch the former! FIXED>> echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; Ok, I lied... I'm not really gonna use it. Interesting tidbit of obfuscation though. BTW... the following is shorter: echo ${~${''}='sillyFunc'}['e'] . PHP_EOL; Cheers, Rob. but doesn't work over here.. php 5.2.4 && 5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, 2008-02-28 at 23:27 -0500, Robert Cummings wrote: > On Fri, 2008-02-29 at 04:04 +, Nathan Rixham wrote: > > Robert Cummings wrote: > > > On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: > > >> don't say I didn't warn ya fellow nathan! > > >> > > >> #!/usr/bin/php > > >> > >> function sillyFunc() { > > >> return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some > > >> string'); > > >> } > > >> > > >> echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; > > > > > > > > > I was ready to use this system everywhere in my code until I saw that it > > > generates an E_STRICT... now I'll just have to keep with what I usually > > > do. > > > > > > Cheers, > > > Rob. > > > > scratch the former! > > > > FIXED>> > > > > echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; > > Ok, I lied... I'm not really gonna use it. Interesting tidbit of > obfuscation though. BTW... the following is shorter: echo ${~${''}='sillyFunc'}['e'] . PHP_EOL; 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Fri, 2008-02-29 at 04:04 +, Nathan Rixham wrote: > Robert Cummings wrote: > > On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: > >> don't say I didn't warn ya fellow nathan! > >> > >> #!/usr/bin/php > >> >> function sillyFunc() { > >>return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some > >> string'); > >> } > >> > >> echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; > > > > > > I was ready to use this system everywhere in my code until I saw that it > > generates an E_STRICT... now I'll just have to keep with what I usually > > do. > > > > Cheers, > > Rob. > > scratch the former! > > FIXED>> > > echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; Ok, I lied... I'm not really gonna use it. Interesting tidbit of obfuscation though. 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
Robert Cummings wrote: On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: don't say I didn't warn ya fellow nathan! #!/usr/bin/php 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some string'); } echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; I was ready to use this system everywhere in my code until I saw that it generates an E_STRICT... now I'll just have to keep with what I usually do. Cheers, Rob. scratch the former! FIXED>> echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
Robert Cummings wrote: On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: don't say I didn't warn ya fellow nathan! #!/usr/bin/php 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some string'); } echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; I was ready to use this system everywhere in my code until I saw that it generates an E_STRICT... now I'll just have to keep with what I usually do. Cheers, Rob. fixed :) #!/usr/bin/php return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some string'); } #echo !${~${''}='sillyFunc'}=${''}().${~${''}}['e'] . PHP_EOL; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: > > don't say I didn't warn ya fellow nathan! > > #!/usr/bin/php > function sillyFunc() { > return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some > string'); > } > > echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; I was ready to use this system everywhere in my code until I saw that it generates an E_STRICT... now I'll just have to keep with what I usually do. 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
Nathan Nobbe wrote: On Thu, Feb 28, 2008 at 6:14 PM, Nathan Rixham <[EMAIL PROTECTED]> 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 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 :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, Feb 28, 2008 at 6:14 PM, Nathan Rixham <[EMAIL PROTECTED]> 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
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, Feb 28, 2008 at 4:22 PM, Jim Lucas <[EMAIL PROTECTED]> wrote: > So, I guess my question would be, why not take it one level deeper. > > include('ArrayClass.php'); > > function sillyFunc() { > return ArrayClass::create(array('a' => 1, 'b' => 2, 'c' => 3, 'd' => > 4)); > } > > echo sillyFunc()->a . PHP_EOL; > ?> the idea is that you get something that can be used repeatedly. in your example you are creating the array that is supplied to the ArrayClass::create() method, whereas in mine it is supplied by something else. of course you could create a global function that wraps the ArrayClass::create() method, and in that case it might make sense to leave the constructor public and just wrap the instantiation of the ArrayClass class. but thats why i created the static method in the first place, that and the issue we observed a while back about not being able to invoke a method on an object in the same statement that instantiates it. -nathan
Re: [PHP] echo returnArray()['a']; // workaround
Nathan Nobbe wrote: On Thu, Feb 28, 2008 at 2:36 PM, Ray Hauge <[EMAIL PROTECTED]> wrote: That's pretty cool. I wasn't sure if it would work with numerically indexed arrays, so I tried: // sillyFunc returns array(0=>1, 1=>2); ArrayClass::create(sillyFunc())->{"0"} I just tested it, and that works. If you leave off the curly braces and quotes, then you obviously get a parse error. The curly braces are necessary. cool, thanks for the tip :) -nathan 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* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
Nathan Nobbe wrote: all, as we have discussed previously, php does not have support for retrieving array values on the same line in which they are returned. i have created a simple workaround, and would like to share. first there is the class (w/ other features omitted for the post) theArray = $theArray; } public static function create($theArray) { return new ArrayClass($theArray); } public function __get($name) { if($this->isValidKey($name)) { return $this->theArray[$name]; } } private function isValidKey($name) { $isValidKey = false; if(array_key_exists($name, $this->theArray)) { $isValidKey = true; } return $isValidKey; } } ?> and then there is the example, 1, 'b' => 2, 'c' => 3, 'd' => 4); } echo ArrayClass::create(sillyFunc())->a . PHP_EOL; ?> notice what would be echo sillyFunc()['a'] . PHP_EOL; becomes what you see above. -nathan ps. sorry for all the extra newlines; im trying to work w/ the alterations the list server is applying to my posts so bear w/ me :D So, I guess my question would be, why not take it one level deeper. 1, 'b' => 2, 'c' => 3, 'd' => 4)); } echo sillyFunc()->a . PHP_EOL; ?> -- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, Feb 28, 2008 at 2:16 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > all, > > as we have discussed previously, php does not have support for retrieving > array values on the same line in which they are returned. i have created a > simple workaround, and would like to share. first there is the class (w/ > other features omitted for the post) >class ArrayClass { > private $theArray = null; > > private function __construct($theArray) { > if(!is_array($theArray)) { > throw UnexpectedValueException('theArray must be an array!'); > } > $this->theArray = $theArray; > } > > public static function create($theArray) { > return new ArrayClass($theArray); > } > > public function __get($name) { > if($this->isValidKey($name)) { > return $this->theArray[$name]; > } > } > > private function isValidKey($name) { > $isValidKey = false; > if(array_key_exists($name, $this->theArray)) { > $isValidKey = true; > } > return $isValidKey; > } > } > ?> > > and then there is the example, > >include('ArrayClass.php'); > > function sillyFunc() { > return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4); > } > > echo ArrayClass::create(sillyFunc())->a . PHP_EOL; > ?> > > notice what would be > > echo sillyFunc()['a'] . PHP_EOL; > > becomes what you see above. > > -nathan > > ps. sorry for all the extra newlines; im trying to work w/ the alterations > the list server is applying to my posts so bear w/ me :D > That is funny & interesting. If you're only using text keys you can do this: 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some string'); } function objectize($val) { return (object)$val; } var_dump( objectize(sillyFunc())->a ); var_dump( objectize(sillyFunc())->e ); --- output --- int 1 string 'some string' (length=11) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, Feb 28, 2008 at 2:36 PM, Ray Hauge <[EMAIL PROTECTED]> wrote: > That's pretty cool. I wasn't sure if it would work with numerically > indexed arrays, so I tried: > > // sillyFunc returns array(0=>1, 1=>2); > > ArrayClass::create(sillyFunc())->{"0"} > > I just tested it, and that works. If you leave off the curly braces and > quotes, then you obviously get a parse error. The curly braces are > necessary. cool, thanks for the tip :) -nathan
Re: [PHP] echo returnArray()['a']; // workaround
Nathan Nobbe wrote: all, as we have discussed previously, php does not have support for retrieving array values on the same line in which they are returned. i have created a simple workaround, and would like to share. first there is the class (w/ other features omitted for the post) theArray = $theArray; } public static function create($theArray) { return new ArrayClass($theArray); } public function __get($name) { if($this->isValidKey($name)) { return $this->theArray[$name]; } } private function isValidKey($name) { $isValidKey = false; if(array_key_exists($name, $this->theArray)) { $isValidKey = true; } return $isValidKey; } } ?> and then there is the example, 1, 'b' => 2, 'c' => 3, 'd' => 4); } echo ArrayClass::create(sillyFunc())->a . PHP_EOL; ?> notice what would be echo sillyFunc()['a'] . PHP_EOL; becomes what you see above. -nathan ps. sorry for all the extra newlines; im trying to work w/ the alterations the list server is applying to my posts so bear w/ me :D That's pretty cool. I wasn't sure if it would work with numerically indexed arrays, so I tried: // sillyFunc returns array(0=>1, 1=>2); ArrayClass::create(sillyFunc())->{"0"} I just tested it, and that works. If you leave off the curly braces and quotes, then you obviously get a parse error. The curly braces are necessary. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo returnArray()['a']; // workaround
all, as we have discussed previously, php does not have support for retrieving array values on the same line in which they are returned. i have created a simple workaround, and would like to share. first there is the class (w/ other features omitted for the post) theArray = $theArray; } public static function create($theArray) { return new ArrayClass($theArray); } public function __get($name) { if($this->isValidKey($name)) { return $this->theArray[$name]; } } private function isValidKey($name) { $isValidKey = false; if(array_key_exists($name, $this->theArray)) { $isValidKey = true; } return $isValidKey; } } ?> and then there is the example, 1, 'b' => 2, 'c' => 3, 'd' => 4); } echo ArrayClass::create(sillyFunc())->a . PHP_EOL; ?> notice what would be echo sillyFunc()['a'] . PHP_EOL; becomes what you see above. -nathan ps. sorry for all the extra newlines; im trying to work w/ the alterations the list server is applying to my posts so bear w/ me :D
Re: [PHP] echo VS print : that's a cool behavior !
That's just the case : "too see what happens if ...". I agree that anyone will never meet such a case in everydays' programming. ;-) 2007/10/23, Andrew Ballard <[EMAIL PROTECTED]>: > > On 10/23/07, Robert Cummings <[EMAIL PROTECTED]> wrote: > > My bad, print is not a function, and so: > > > > print( 'toctoc ' ).'hihi '; > > > > is equivalent to: > > > > print( 'tocktoc '.'hihi ' ); > > > > Ah. I see. I knew they were optional, but I didn't know that when you > include them PHP evaluates ('toctoc') before it passes the value off > to print(). I just figured that with or without the parentheses it > would pass 'toctoc' to print() and return a result that would be > concatenated inline with the other values. I guess that's the part I > didn't understand about the difference between a function and a > language construct in PHP. > > As for the OP, I still don't know why anyone would even dream of > creating code that does this other than "to see what would happen if > we " :-) > > Andrew > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] echo VS print : that's a cool behavior !
On 10/23/07, Robert Cummings <[EMAIL PROTECTED]> wrote: > My bad, print is not a function, and so: > > print( 'toctoc ' ).'hihi '; > > is equivalent to: > > print( 'tocktoc '.'hihi ' ); > Ah. I see. I knew they were optional, but I didn't know that when you include them PHP evaluates ('toctoc') before it passes the value off to print(). I just figured that with or without the parentheses it would pass 'toctoc' to print() and return a result that would be concatenated inline with the other values. I guess that's the part I didn't understand about the difference between a function and a language construct in PHP. As for the OP, I still don't know why anyone would even dream of creating code that does this other than "to see what would happen if we " :-) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo VS print : that's a cool behavior !
On Tue, 2007-10-23 at 11:54 -0400, Andrew Ballard wrote: > On 10/23/07, Robert Cummings <[EMAIL PROTECTED]> wrote: > > On Tue, 2007-10-23 at 17:34 +0200, Julien Pauli wrote: > > > > > echo "coucou " . print('v ' . print('u ' . print('toctoc ') . 'hihi > > > ') ) . > > > 'tata ' . print('zozo ' . print('pupu ')); > > > > That's not cool, that's a mess. Why doe sit happen the way it does? > > First off, print() is a function so nesting functions means the > > innermost functions get processed first, this is why the output has > > mangled order. The 1's show up in the output because you're > > concatenating the return value of the print() function which is true for > > success. > > Agreed it's a mess, and I don't know why anyone would do it, but > that's only part of the story. I don't think the OP was wondering > where the 1s came from; at least I'm not. I am wondering why it > displays: > > toctoc hihi u 1pupu zozo 1v 1tata 1coucou 1 > > instead of > > toctoc u 1hihi v 1pupu zozo 1coucou 1tata 1 My bad, print is not a function, and so: print( 'toctoc ' ).'hihi '; is equivalent to: print( 'tocktoc '.'hihi ' ); Parenthesis are option and only server to control precedence. But unlike echo print does return a value. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] echo VS print : that's a cool behavior !
> Hello everyone. > > We all know the difference between print and echo, but has someone ever > tried to combine them together ?? > > Right, try this : > > echo "coucou " . print('v ' . print('u ' . print('toctoc ') . 'hihi ') ) . > 'tata ' . print('zozo ' . print('pupu ')); > > > And guess the result ... > > Can someone explain it ? > ( the result is : toctoc hihi u 1pupu zozo 1v 1tata 1coucou 1 ) Precedence. _ Windows Live Hotmail and Microsoft Office Outlook – together at last. Get it now. http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033
Re: [PHP] echo VS print : that's a cool behavior !
At 11:46 AM -0400 10/23/07, Robert Cummings wrote: On Tue, 2007-10-23 at 17:34 +0200, Julien Pauli wrote: That's not cool, that's a mess. Why doe sit happen the way it does? First off, print() is a function so nesting functions means the innermost functions get processed first, this is why the output has mangled order. The 1's show up in the output because you're concatenating the return value of the print() function which is true for success. Cheers, Rob. -- Rob: Good call on the 1 return. Maybe this will help: http://www.webbytedd.com/bbb/echo-print/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo VS print : that's a cool behavior !
On 10/23/07, Robert Cummings <[EMAIL PROTECTED]> wrote: > On Tue, 2007-10-23 at 17:34 +0200, Julien Pauli wrote: > > > echo "coucou " . print('v ' . print('u ' . print('toctoc ') . 'hihi > > ') ) . > > 'tata ' . print('zozo ' . print('pupu ')); > > That's not cool, that's a mess. Why doe sit happen the way it does? > First off, print() is a function so nesting functions means the > innermost functions get processed first, this is why the output has > mangled order. The 1's show up in the output because you're > concatenating the return value of the print() function which is true for > success. Agreed it's a mess, and I don't know why anyone would do it, but that's only part of the story. I don't think the OP was wondering where the 1s came from; at least I'm not. I am wondering why it displays: toctoc hihi u 1pupu zozo 1v 1tata 1coucou 1 instead of toctoc u 1hihi v 1pupu zozo 1coucou 1tata 1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo VS print : that's a cool behavior !
On Tue, 2007-10-23 at 17:34 +0200, Julien Pauli wrote: > echo "coucou " . print('v ' . print('u ' . print('toctoc ') . 'hihi > ') ) . > 'tata ' . print('zozo ' . print('pupu ')); That's not cool, that's a mess. Why doe sit happen the way it does? First off, print() is a function so nesting functions means the innermost functions get processed first, this is why the output has mangled order. The 1's show up in the output because you're concatenating the return value of the print() function which is true for success. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo VS print : that's a cool behavior !
Hello everyone. We all know the difference between print and echo, but has someone ever tried to combine them together ?? Right, try this :
Re: [PHP] echo date('Y-m-d', $mydata->timestamp);
Use the MySQL function that converts timestamp into Unixtime. Or, better yet, use the MySQL function that outputs exactly the date format you want, without dinking around with Unix timestamp in the middle. http://dev.mysql.com/ Search for date_format() I do believe. It's gonna be a whole lot like PHP 'date' function, only with % signs, as I recall. On Sun, April 22, 2007 1:33 am, John Taylor-Johnston wrote: > > It is actually a generated timestamp in MySQL. > timestamp(14) > Now what? I was hoping to avoid: > |echo substr(|$mydata->timestamp|, 0, 8); > > John > > |Richard Lynch wrote: >> On Sun, April 22, 2007 1:05 am, John Taylor-Johnston wrote: >> >>> $mydata->timestamp = "20070419162123"; >>> >>> echo date('Y-m-d', $mydata->timestamp); >>> >>> >>> result: 2038-01-18 >>> >>> ?? What is wrong?? Should be 2007-04-19? >>> >> >> date() takes a Unix timestamp as its input. >> >> Unix timestamps are measured as number of seconds from Jan 1, 1970, >> midnight, GMT, the birth of Disco. >> [that last was a joke...] >> >> You are handing it a pre-formatted date-stamp in MMDDHHIISS >> format... >> >> You could do something like: >> $t = '20070419162123'; >> $year = substr($t, 0, 4); >> $month = substr($t, 4, 2); >> $day = substr($t, 6, 2); >> $hour = substr($t, 8, 2); >> $minutes = substr($t, 10, 2); >> $seconds = substr($t, 12, 2); >> echo date(mktime($month, $day, $year, $hour, $minutes, $seconds)); >> >> I suspect strtotime() *might* handle your input and give you a Unix >> timestamp... >> >> I also suspect whatever you needed a Unix timestamp for in the first >> place could have been achieved easier before you got painted into >> this >> corner... >> >> > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] echo date('Y-m-d', $mydata->timestamp);
You are misunderstanding what timestamp means. The value of a timestamp is from UNIX epoch http://en.wikipedia.org/wiki/Unix_time. It is calculated by the number of seconds after January 1st, 1970. Also note, that you are overflowing the integer, which is giving you a http://en.wikipedia.org/wiki/Year_2038_problem Y2K38 problem. If you want the UNIX timestamp of 4/19/2007 16:21:23, you can do mktime(16,21,23,4,19,2007); (http://us.php.net/manual/en/function.mktime.php). -Logan -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Sunday, April 22, 2007 2:05 AM To: PHP-General Cc: John Taylor-Johnston Subject: [PHP] echo date('Y-m-d', $mydata->timestamp); $mydata->timestamp = "20070419162123"; echo date('Y-m-d', $mydata->timestamp); result: 2038-01-18 ?? What is wrong?? Should be 2007-04-19? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo date('Y-m-d', $mydata->timestamp);
John Taylor-Johnston wrote: > > It is actually a generated timestamp in MySQL. > timestamp(14) > Now what? I was hoping to avoid: > |echo substr(|$mydata->timestamp|, 0, 8); the simplest answer is actually yto make mySQL give you the data in unix timestamp format in the first place: SELECT UNIX_TIMESTAMP(my_field) AS my_timestamp FROM foo WHERE id=1; > > John > > |Richard Lynch wrote: >> On Sun, April 22, 2007 1:05 am, John Taylor-Johnston wrote: >> >>> $mydata->timestamp = "20070419162123"; >>> >>> echo date('Y-m-d', $mydata->timestamp); >>> >>> >>> result: 2038-01-18 >>> >>> ?? What is wrong?? Should be 2007-04-19? >>> >> >> date() takes a Unix timestamp as its input. >> >> Unix timestamps are measured as number of seconds from Jan 1, 1970, >> midnight, GMT, the birth of Disco. >> [that last was a joke...] >> >> You are handing it a pre-formatted date-stamp in MMDDHHIISS format... >> >> You could do something like: >> $t = '20070419162123'; >> $year = substr($t, 0, 4); >> $month = substr($t, 4, 2); >> $day = substr($t, 6, 2); >> $hour = substr($t, 8, 2); >> $minutes = substr($t, 10, 2); >> $seconds = substr($t, 12, 2); >> echo date(mktime($month, $day, $year, $hour, $minutes, $seconds)); >> >> I suspect strtotime() *might* handle your input and give you a Unix >> timestamp... >> >> I also suspect whatever you needed a Unix timestamp for in the first >> place could have been achieved easier before you got painted into this >> corner... >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo date('Y-m-d', $mydata->timestamp);
On Sunday 22 April 2007 08:33, John Taylor-Johnston wrote: > It is actually a generated timestamp in MySQL. > timestamp(14) Well, then just use the query to decide how it should look like. Mysql timestamp is amazingly easy to work with. whatevertable,date_format(timestamp_table, 'what should it look like') as timestamp or use another name if you need both like I do. > > Now what? I was hoping to avoid: > |echo substr(|$mydata->timestamp|, 0, 8); > > John > > |Richard Lynch wrote: > | > > On Sun, April 22, 2007 1:05 am, John Taylor-Johnston wrote: > >> $mydata->timestamp = "20070419162123"; > >> > >> echo date('Y-m-d', $mydata->timestamp); > >> > >> > >> result: 2038-01-18 > >> > >> ?? What is wrong?? Should be 2007-04-19? > > > > date() takes a Unix timestamp as its input. > > > > Unix timestamps are measured as number of seconds from Jan 1, 1970, > > midnight, GMT, the birth of Disco. > > [that last was a joke...] > > > > You are handing it a pre-formatted date-stamp in MMDDHHIISS format... > > > > You could do something like: > > $t = '20070419162123'; > > $year = substr($t, 0, 4); > > $month = substr($t, 4, 2); > > $day = substr($t, 6, 2); > > $hour = substr($t, 8, 2); > > $minutes = substr($t, 10, 2); > > $seconds = substr($t, 12, 2); > > echo date(mktime($month, $day, $year, $hour, $minutes, $seconds)); > > > > I suspect strtotime() *might* handle your input and give you a Unix > > timestamp... > > > > I also suspect whatever you needed a Unix timestamp for in the first > > place could have been achieved easier before you got painted into this > > corner... -- --- Børge http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo date('Y-m-d', $mydata->timestamp);
It is actually a generated timestamp in MySQL. timestamp(14) Now what? I was hoping to avoid: |echo substr(|$mydata->timestamp|, 0, 8); John |Richard Lynch wrote: On Sun, April 22, 2007 1:05 am, John Taylor-Johnston wrote: $mydata->timestamp = "20070419162123"; echo date('Y-m-d', $mydata->timestamp); result: 2038-01-18 ?? What is wrong?? Should be 2007-04-19? date() takes a Unix timestamp as its input. Unix timestamps are measured as number of seconds from Jan 1, 1970, midnight, GMT, the birth of Disco. [that last was a joke...] You are handing it a pre-formatted date-stamp in MMDDHHIISS format... You could do something like: $t = '20070419162123'; $year = substr($t, 0, 4); $month = substr($t, 4, 2); $day = substr($t, 6, 2); $hour = substr($t, 8, 2); $minutes = substr($t, 10, 2); $seconds = substr($t, 12, 2); echo date(mktime($month, $day, $year, $hour, $minutes, $seconds)); I suspect strtotime() *might* handle your input and give you a Unix timestamp... I also suspect whatever you needed a Unix timestamp for in the first place could have been achieved easier before you got painted into this corner...
Re: [PHP] echo date('Y-m-d', $mydata->timestamp);
On Sun, April 22, 2007 1:05 am, John Taylor-Johnston wrote: > $mydata->timestamp = "20070419162123"; > > echo date('Y-m-d', $mydata->timestamp); > > > result: 2038-01-18 > > ?? What is wrong?? Should be 2007-04-19? date() takes a Unix timestamp as its input. Unix timestamps are measured as number of seconds from Jan 1, 1970, midnight, GMT, the birth of Disco. [that last was a joke...] You are handing it a pre-formatted date-stamp in MMDDHHIISS format... You could do something like: $t = '20070419162123'; $year = substr($t, 0, 4); $month = substr($t, 4, 2); $day = substr($t, 6, 2); $hour = substr($t, 8, 2); $minutes = substr($t, 10, 2); $seconds = substr($t, 12, 2); echo date(mktime($month, $day, $year, $hour, $minutes, $seconds)); I suspect strtotime() *might* handle your input and give you a Unix timestamp... I also suspect whatever you needed a Unix timestamp for in the first place could have been achieved easier before you got painted into this corner... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo date('Y-m-d', $mydata->timestamp);
$mydata->timestamp = "20070419162123"; echo date('Y-m-d', $mydata->timestamp); result: 2038-01-18 ?? What is wrong?? Should be 2007-04-19? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
On Sat, April 21, 2007 5:20 pm, Tijnema ! wrote: > But what else would you use a lot in your code? > all commonly used things (like while, if, echo, etc) are just (nearly) > as fast as their alternatives (for, print, etc). > Other functions (like file/stream) might be some performance > difference, but you probably use this only a few times in your script. > So there's not a bigger performance difference then when optimizing > echo/print. You use valgrind/callgrind and find out where your bottlenecks are and optimize those. You also benchmark your non-PHP stuff which is often the bottleneck in the first place. Optimizing random bits of code that aren't your bottleneck is just wasting your most precious resource: YOUR TIME! -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
Tijnema ! wrote: On 4/22/07, Stut <[EMAIL PROTECTED]> wrote: Tijnema ! wrote: > But what else would you use a lot in your code? > all commonly used things (like while, if, echo, etc) are just (nearly) > as fast as their alternatives (for, print, etc). > Other functions (like file/stream) might be some performance > difference, but you probably use this only a few times in your script. > So there's not a bigger performance difference then when optimizing > echo/print. Get your head out of the details. Try file-based caching against DB access. And compare that with RAM caching ;) Or SQL query optimisation. Or even server configuration tuning. All these things and others on the same level are far more worthy of your time. -Stut So, optimizing is useless :P I see no point in doing it, even more when it's only for personal usage. The time used for writing optimized code is probably far more then the time you save by running optimized code. :) I hope that smiley means you're joking. Optimising is not useless, and I've never said it is. However, you have to do so where it's going to have the biggest impact. What I'm basically saying is you should be optimising logic before even thinking about whether you're using the most optimised functions. Are you sure that your code doesn't do anything it doesn't need to? Do you do a whole load of initialisation for each request that could be cached in some way? Is every part of that initialisation needed for every page request, or should it be doing different things on different pages. IMHO, the kind of developer that gets hung up on details like echo or print is one that is unlikely to accomplish a lot in any given day. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
On 4/22/07, Stut <[EMAIL PROTECTED]> wrote: Tijnema ! wrote: > But what else would you use a lot in your code? > all commonly used things (like while, if, echo, etc) are just (nearly) > as fast as their alternatives (for, print, etc). > Other functions (like file/stream) might be some performance > difference, but you probably use this only a few times in your script. > So there's not a bigger performance difference then when optimizing > echo/print. Get your head out of the details. Try file-based caching against DB access. And compare that with RAM caching ;) Or SQL query optimisation. Or even server configuration tuning. All these things and others on the same level are far more worthy of your time. -Stut So, optimizing is useless :P I see no point in doing it, even more when it's only for personal usage. The time used for writing optimized code is probably far more then the time you save by running optimized code. :) Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
Tijnema ! wrote: But what else would you use a lot in your code? all commonly used things (like while, if, echo, etc) are just (nearly) as fast as their alternatives (for, print, etc). Other functions (like file/stream) might be some performance difference, but you probably use this only a few times in your script. So there's not a bigger performance difference then when optimizing echo/print. Get your head out of the details. Try file-based caching against DB access. Or SQL query optimisation. Or even server configuration tuning. All these things and others on the same level are far more worthy of your time. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
On 4/21/07, Stut <[EMAIL PROTECTED]> wrote: Tijnema ! wrote: > On 4/21/07, Stut <[EMAIL PROTECTED]> wrote: >> Tijnema ! wrote: >> > There is a difference, echo is slightly faster. >> > code used for benchmark: >> > > > $start = microtime(TRUE); >> > for ($i=0; $i<10; ++$i) { print "ABC"; } >> > echo sprintf("With print ($i): %0.3f\n",microtime(TRUE) - $start); >> > $start = microtime(TRUE); >> > for ($i=0; $i<10; ++$i) { echo "ABC"; } >> > echo sprintf("With echo ($i): %0.3f\n",microtime(TRUE) - $start); >> > ?> >> > >> > it displays 10 times ABC, first with the print command, and second >> > with the echo command. Result: >> > ABCABCABC >> > print (10): 0.085 >> > ABCABCABC >> > echo (10): 0.076 >> > >> > >> > It's not a lot, but since we are displaying data a lot, (most used >> > function?) it will make a difference in really big scripts. >> >> This has been covered before. The difference actually depends on how >> you're using it, rather than whether you use print or echo. For example, >> your benchmark shows echo to be slightly faster, but the the following >> script that I wrote last time this came up shows the opposite. The only >> difference is that you're outputting a literal whereas I'm printing a >> variable. >> >>http://dev.stut.net/phpspeed/ >> >> At the end of the day there are more important things to worry about, >> especially when you're talking in the region of 0.009 seconds per >> 100,000 calls it's not going to make anywhere near a significant >> difference to any script you write, even really really big ones scripts. >> >> To put it another way, you would need to make 10,000,000 calls for it to >> extend the runtime of your script by 1 second. Granted you might have a >> script that calls it 1000 times, meaning 10,000 requests to that script >> would "waste" 1 second. But unless you're getting twitter-like levels of >> traffic (they spike at over 11k hits a second) it's not worth worrying >> about, and I'm guessing (hoping) their devs probably wouldn't care >> either. >> >> Get over it and concentrate on the functionality and usability of your >> code rather than insignificant details like this. >> >> -Stut > > Interesting :) > > I see there's no big difference between echo and print, but that > is faster :) > > I've learned (not only from this) that whatever you do in PHP is fast, > and that you don't need to optimize your code for speed. Unless you're > hitting 100k+ hits per hour. But even then it would only save you > maybe one hour per year. I wouldn't go that far. It is definitely possible to write horribly inefficient code with PHP. Believe me, I've inherited enough crap code in my lifetime to testify to that. My point was simply that you need to look at the numbers from benchmarks in perspective, and when efficiency is concerned there's almost always far bigger gains to be made than 0.009 seconds per 100,000 calls to output something. -Stut But what else would you use a lot in your code? all commonly used things (like while, if, echo, etc) are just (nearly) as fast as their alternatives (for, print, etc). Other functions (like file/stream) might be some performance difference, but you probably use this only a few times in your script. So there's not a bigger performance difference then when optimizing echo/print. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
Tijnema ! wrote: On 4/21/07, Stut <[EMAIL PROTECTED]> wrote: Tijnema ! wrote: > There is a difference, echo is slightly faster. > code used for benchmark: > $start = microtime(TRUE); > for ($i=0; $i<10; ++$i) { print "ABC"; } > echo sprintf("With print ($i): %0.3f\n",microtime(TRUE) - $start); > $start = microtime(TRUE); > for ($i=0; $i<10; ++$i) { echo "ABC"; } > echo sprintf("With echo ($i): %0.3f\n",microtime(TRUE) - $start); > ?> > > it displays 10 times ABC, first with the print command, and second > with the echo command. Result: > ABCABCABC > print (10): 0.085 > ABCABCABC > echo (10): 0.076 > > > It's not a lot, but since we are displaying data a lot, (most used > function?) it will make a difference in really big scripts. This has been covered before. The difference actually depends on how you're using it, rather than whether you use print or echo. For example, your benchmark shows echo to be slightly faster, but the the following script that I wrote last time this came up shows the opposite. The only difference is that you're outputting a literal whereas I'm printing a variable. http://dev.stut.net/phpspeed/ At the end of the day there are more important things to worry about, especially when you're talking in the region of 0.009 seconds per 100,000 calls it's not going to make anywhere near a significant difference to any script you write, even really really big ones scripts. To put it another way, you would need to make 10,000,000 calls for it to extend the runtime of your script by 1 second. Granted you might have a script that calls it 1000 times, meaning 10,000 requests to that script would "waste" 1 second. But unless you're getting twitter-like levels of traffic (they spike at over 11k hits a second) it's not worth worrying about, and I'm guessing (hoping) their devs probably wouldn't care either. Get over it and concentrate on the functionality and usability of your code rather than insignificant details like this. -Stut Interesting :) I see there's no big difference between echo and print, but that is faster :) I've learned (not only from this) that whatever you do in PHP is fast, and that you don't need to optimize your code for speed. Unless you're hitting 100k+ hits per hour. But even then it would only save you maybe one hour per year. I wouldn't go that far. It is definitely possible to write horribly inefficient code with PHP. Believe me, I've inherited enough crap code in my lifetime to testify to that. My point was simply that you need to look at the numbers from benchmarks in perspective, and when efficiency is concerned there's almost always far bigger gains to be made than 0.009 seconds per 100,000 calls to output something. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
On 4/21/07, Stut <[EMAIL PROTECTED]> wrote: Tijnema ! wrote: > On 4/18/07, Richard Lynch <[EMAIL PROTECTED]> wrote: >> On Tue, April 17, 2007 1:40 am, Christian Haensel wrote: >> > Whenever I see people put their code up for review, I realize they >> > mostly >> > use print instead of echo, while I am using echo 99% of the time. >> > Actually, >> > I can't even remember when I last used the regular print. >> >> There used to be a difference, but not really any more, I don't think. >> >> Or does print still not allow multiple arguments?... >> >> > What do you guys use, and what is the advantage (if ther is any) of >> > print >> > over echo? And I am not talking about print_r or anything, just the >> > regular >> > print. :o) >> >> I use echo, because I'm old, and got in the habit, back when print() >> was a function and echo was a language construct, and only echo let >> you have as many args with commas as you wanted. >> >> But there's no significant difference, as far as I know. > > There is a difference, echo is slightly faster. > code used for benchmark: > $start = microtime(TRUE); > for ($i=0; $i<10; ++$i) { print "ABC"; } > echo sprintf("With print ($i): %0.3f\n",microtime(TRUE) - $start); > $start = microtime(TRUE); > for ($i=0; $i<10; ++$i) { echo "ABC"; } > echo sprintf("With echo ($i): %0.3f\n",microtime(TRUE) - $start); > ?> > > it displays 10 times ABC, first with the print command, and second > with the echo command. Result: > ABCABCABC > print (10): 0.085 > ABCABCABC > echo (10): 0.076 > > > It's not a lot, but since we are displaying data a lot, (most used > function?) it will make a difference in really big scripts. This has been covered before. The difference actually depends on how you're using it, rather than whether you use print or echo. For example, your benchmark shows echo to be slightly faster, but the the following script that I wrote last time this came up shows the opposite. The only difference is that you're outputting a literal whereas I'm printing a variable. http://dev.stut.net/phpspeed/ At the end of the day there are more important things to worry about, especially when you're talking in the region of 0.009 seconds per 100,000 calls it's not going to make anywhere near a significant difference to any script you write, even really really big ones scripts. To put it another way, you would need to make 10,000,000 calls for it to extend the runtime of your script by 1 second. Granted you might have a script that calls it 1000 times, meaning 10,000 requests to that script would "waste" 1 second. But unless you're getting twitter-like levels of traffic (they spike at over 11k hits a second) it's not worth worrying about, and I'm guessing (hoping) their devs probably wouldn't care either. Get over it and concentrate on the functionality and usability of your code rather than insignificant details like this. -Stut Interesting :) I see there's no big difference between echo and print, but that is faster :) I've learned (not only from this) that whatever you do in PHP is fast, and that you don't need to optimize your code for speed. Unless you're hitting 100k+ hits per hour. But even then it would only save you maybe one hour per year. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
Tijnema ! wrote: On 4/18/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Tue, April 17, 2007 1:40 am, Christian Haensel wrote: > Whenever I see people put their code up for review, I realize they > mostly > use print instead of echo, while I am using echo 99% of the time. > Actually, > I can't even remember when I last used the regular print. There used to be a difference, but not really any more, I don't think. Or does print still not allow multiple arguments?... > What do you guys use, and what is the advantage (if ther is any) of > print > over echo? And I am not talking about print_r or anything, just the > regular > print. :o) I use echo, because I'm old, and got in the habit, back when print() was a function and echo was a language construct, and only echo let you have as many args with commas as you wanted. But there's no significant difference, as far as I know. There is a difference, echo is slightly faster. code used for benchmark: it displays 10 times ABC, first with the print command, and second with the echo command. Result: ABCABCABC print (10): 0.085 ABCABCABC echo (10): 0.076 It's not a lot, but since we are displaying data a lot, (most used function?) it will make a difference in really big scripts. This has been covered before. The difference actually depends on how you're using it, rather than whether you use print or echo. For example, your benchmark shows echo to be slightly faster, but the the following script that I wrote last time this came up shows the opposite. The only difference is that you're outputting a literal whereas I'm printing a variable. http://dev.stut.net/phpspeed/ At the end of the day there are more important things to worry about, especially when you're talking in the region of 0.009 seconds per 100,000 calls it's not going to make anywhere near a significant difference to any script you write, even really really big ones scripts. To put it another way, you would need to make 10,000,000 calls for it to extend the runtime of your script by 1 second. Granted you might have a script that calls it 1000 times, meaning 10,000 requests to that script would "waste" 1 second. But unless you're getting twitter-like levels of traffic (they spike at over 11k hits a second) it's not worth worrying about, and I'm guessing (hoping) their devs probably wouldn't care either. Get over it and concentrate on the functionality and usability of your code rather than insignificant details like this. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
On 4/18/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Tue, April 17, 2007 1:40 am, Christian Haensel wrote: > Whenever I see people put their code up for review, I realize they > mostly > use print instead of echo, while I am using echo 99% of the time. > Actually, > I can't even remember when I last used the regular print. There used to be a difference, but not really any more, I don't think. Or does print still not allow multiple arguments?... > What do you guys use, and what is the advantage (if ther is any) of > print > over echo? And I am not talking about print_r or anything, just the > regular > print. :o) I use echo, because I'm old, and got in the habit, back when print() was a function and echo was a language construct, and only echo let you have as many args with commas as you wanted. But there's no significant difference, as far as I know. There is a difference, echo is slightly faster. code used for benchmark: it displays 10 times ABC, first with the print command, and second with the echo command. Result: ABCABCABC print (10): 0.085 ABCABCABC echo (10): 0.076 It's not a lot, but since we are displaying data a lot, (most used function?) it will make a difference in really big scripts. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
On Tue, April 17, 2007 1:40 am, Christian Haensel wrote: > Whenever I see people put their code up for review, I realize they > mostly > use print instead of echo, while I am using echo 99% of the time. > Actually, > I can't even remember when I last used the regular print. There used to be a difference, but not really any more, I don't think. Or does print still not allow multiple arguments?... > What do you guys use, and what is the advantage (if ther is any) of > print > over echo? And I am not talking about print_r or anything, just the > regular > print. :o) I use echo, because I'm old, and got in the habit, back when print() was a function and echo was a language construct, and only echo let you have as many args with commas as you wanted. But there's no significant difference, as far as I know. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
Thanks mate, that clarifies that. And now I know why I use echo all the time *g* Have a great day,... greetings from sunny germany :o) Chris - Original Message - From: "Dimiter Ivanov" <[EMAIL PROTECTED]> To: "Christian Haensel" <[EMAIL PROTECTED]> Cc: Sent: Tuesday, April 17, 2007 9:48 AM Subject: Re: [PHP] echo or print ? On 4/17/07, Christian Haensel <[EMAIL PROTECTED]> wrote: Good morning fellow coders I've been working with PHP for a little over 5 years now, and it even got me a cute office and a good salary... but even though I can make a living off of it, I am still wondering about a few little things. Whenever I see people put their code up for review, I realize they mostly use print instead of echo, while I am using echo 99% of the time. Actually, I can't even remember when I last used the regular print. What do you guys use, and what is the advantage (if ther is any) of print over echo? And I am not talking about print_r or anything, just the regular print. :o) There is a link in the manual about the difference between those two: http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
On 4/17/07, Christian Haensel <[EMAIL PROTECTED]> wrote: Good morning fellow coders I've been working with PHP for a little over 5 years now, and it even got me a cute office and a good salary... but even though I can make a living off of it, I am still wondering about a few little things. Whenever I see people put their code up for review, I realize they mostly use print instead of echo, while I am using echo 99% of the time. Actually, I can't even remember when I last used the regular print. What do you guys use, and what is the advantage (if ther is any) of print over echo? And I am not talking about print_r or anything, just the regular print. :o) There is a link in the manual about the difference between those two: http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
Me too. I use echo. Print is a function. There's no significant difference between them. My advice: choose one, and stick with it. On 4/16/07, clive <[EMAIL PROTECTED]> wrote: > What do you guys use, and what is the advantage (if ther is any) of > print over echo? And I am not talking about print_r or anything, just > the regular print. :o) print returns a result, echo doesn't. This makes echo slightly faster than print, but I doubt theres any significant speed improvement using echo instead of print. I use echo, but thats just because its a habit. -- Regards, Clive. {No electrons were harmed in the creation, transmission or reading of this email. However, many were excited and some may well have enjoyed the experience.} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print ?
What do you guys use, and what is the advantage (if ther is any) of print over echo? And I am not talking about print_r or anything, just the regular print. :o) print returns a result, echo doesn't. This makes echo slightly faster than print, but I doubt theres any significant speed improvement using echo instead of print. I use echo, but thats just because its a habit. -- Regards, Clive. {No electrons were harmed in the creation, transmission or reading of this email. However, many were excited and some may well have enjoyed the experience.} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo or print ?
Good morning fellow coders I've been working with PHP for a little over 5 years now, and it even got me a cute office and a good salary... but even though I can make a living off of it, I am still wondering about a few little things. Whenever I see people put their code up for review, I realize they mostly use print instead of echo, while I am using echo 99% of the time. Actually, I can't even remember when I last used the regular print. What do you guys use, and what is the advantage (if ther is any) of print over echo? And I am not talking about print_r or anything, just the regular print. :o) All the best! Chris Christian Haensel /voodoo.css #GeorgeWBush { position:absolute; bottom:-6ft; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
Richard Lynch wrote: > You could also use %XX in HEX on the mailto: you can actually randomly mix and match hex and entity encoding, which is what the function I posted elsewhere in the thread does. My function also does that: http://themfund.com/snippets/test.php On 3/1/07, Jochem Maas <[EMAIL PROTECTED]> wrote: Richard Lynch wrote: > You could also use %XX in HEX on the mailto: you can actually randomly mix and match hex and entity encoding, which is what the function I posted elsewhere in the thread does. > > On Tue, February 27, 2007 11:09 pm, Casey Chu wrote: >> It works. =P I tested it. >> >> Try it here! =P >> >> http://themfund.com/snippets/test.php >> >> On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: >>> I'm not sure with both of your questions. I'm too lazy to try. >>> >>> Untested: But to encode it, you would use >>> >>> preg_replace_callback('~([\d\w])~', create_function('$a', 'return >>> "".ord($a[0]).";";'), $theEmail); >>> >>> Hopefully that works? >>> >>> On 2/27/07, John Taylor-Johnston >>> <[EMAIL PROTECTED]> wrote: How do I encode it? And would the href tag work? Casey Chu wrote: > ^ So put that into a tag. > > On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: >> Try using Javascript? Or use all entities? For example: >> mailto:php-general@lists.php.net would turn into >> mailto:php-general@lists.php.net >> >> >> >> >> On 2/27/07, John Taylor-Johnston >> <[EMAIL PROTECTED]> wrote: >>> I need an anti-spam-spider measure for my site. Too many >>> addresses are >>> getting raked. In once instance, I created a flash page: >>> http://erasethis.glquebec.org/English/contact.htm >>> But I just don't have the time to create a flash image for >>> every >> single >>> instance, most of which come from dynamically printed PHP >>> pages from a >>> MySQL database. >>> >>> Could I dynamically create a flash image, input the email and >>> tell the >>> flash image to mailto:[EMAIL PROTECTED] >>> >>> Do anyone have a solution? Does one already exist? >>> >>> My idea was to create a PHP script and output to a png. But I >>> see many >>> problems, including: >>> >>> 1) How do I avoid echoing the email address in the >> href=""> tag? >>> 2) How would I write a png that would be long and high >>> enough? >>> 3) How would the same script display the png? >>> >>> In short, I can't see far enough how to do this and avoid >> spider-raking >>> in the HTML or header the content of the image. >>> >>> Any advice, code or input would be appreciated, >>> John >>> >>> >> echo $??; >>> >>> ?>">>> echo $??; >>> >>> ?>" width="???" height="???"> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
Richard Lynch wrote: > You could also use %XX in HEX on the mailto: you can actually randomly mix and match hex and entity encoding, which is what the function I posted elsewhere in the thread does. > > On Tue, February 27, 2007 11:09 pm, Casey Chu wrote: >> It works. =P I tested it. >> >> Try it here! =P >> >> http://themfund.com/snippets/test.php >> >> On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: >>> I'm not sure with both of your questions. I'm too lazy to try. >>> >>> Untested: But to encode it, you would use >>> >>> preg_replace_callback('~([\d\w])~', create_function('$a', 'return >>> "".ord($a[0]).";";'), $theEmail); >>> >>> Hopefully that works? >>> >>> On 2/27/07, John Taylor-Johnston >>> <[EMAIL PROTECTED]> wrote: How do I encode it? And would the href tag work? Casey Chu wrote: > ^ So put that into a tag. > > On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: >> Try using Javascript? Or use all entities? For example: >> mailto:php-general@lists.php.net would turn into >> mailto:php-general@lists.php.net >> >> >> >> >> On 2/27/07, John Taylor-Johnston >> <[EMAIL PROTECTED]> wrote: >>> I need an anti-spam-spider measure for my site. Too many >>> addresses are >>> getting raked. In once instance, I created a flash page: >>> http://erasethis.glquebec.org/English/contact.htm >>> But I just don't have the time to create a flash image for >>> every >> single >>> instance, most of which come from dynamically printed PHP >>> pages from a >>> MySQL database. >>> >>> Could I dynamically create a flash image, input the email and >>> tell the >>> flash image to mailto:[EMAIL PROTECTED] >>> >>> Do anyone have a solution? Does one already exist? >>> >>> My idea was to create a PHP script and output to a png. But I >>> see many >>> problems, including: >>> >>> 1) How do I avoid echoing the email address in the >> href=""> tag? >>> 2) How would I write a png that would be long and high >>> enough? >>> 3) How would the same script display the png? >>> >>> In short, I can't see far enough how to do this and avoid >> spider-raking >>> in the HTML or header the content of the image. >>> >>> Any advice, code or input would be appreciated, >>> John >>> >>> >> echo $??; >>> >>> ?>">>> echo $??; >>> >>> ?>" width="???" height="???"> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
http://themfund.com/snippets/test.php Has %HEX, entity;, and even a entity version of the hex! On 2/28/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Wed, February 28, 2007 1:20 am, Stut wrote: > Of all the possible methods, entities are the easiest for bots to > handle. They just need to decode the entities. > > More reliable methods involve using javascript to write out the > mailto: > tag. Do it in several statements. But even then, some of the smarter > spiders will execute simple javascript like that. You can make it > better > by using onload to execute the javascript which means the spider will > need to implement that, which I don't believe they do at the moment. > > Of course the best way is to use an image and don't link it. If it's > just a way for visitors to contact you, use a contact form. You don't > expose the email address and can control it a lot better. I'm no expert, but as far as I can tell from my readings on this subject, the reality is that spammers just don't bother to harvest them. Ongoing studies, older studies, newer studies. Everybody knows that the spammers *could* decode HEX or even the JS fairly trivially, but they don't. There are many theories [*] as to why that is, but the empirical evidence is that the obfuscation is very effective at reducing spam dramatically, no matter how silly that seems. * Maybe it's too much low hanging fruit. Maybe they don't want to risk hitting honey-pot emails. Maybe anybody smart enough to obfustcate is too smart to fall for the stupid spam anyway. ... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
On Wed, February 28, 2007 1:20 am, Stut wrote: > Of all the possible methods, entities are the easiest for bots to > handle. They just need to decode the entities. > > More reliable methods involve using javascript to write out the > mailto: > tag. Do it in several statements. But even then, some of the smarter > spiders will execute simple javascript like that. You can make it > better > by using onload to execute the javascript which means the spider will > need to implement that, which I don't believe they do at the moment. > > Of course the best way is to use an image and don't link it. If it's > just a way for visitors to contact you, use a contact form. You don't > expose the email address and can control it a lot better. I'm no expert, but as far as I can tell from my readings on this subject, the reality is that spammers just don't bother to harvest them. Ongoing studies, older studies, newer studies. Everybody knows that the spammers *could* decode HEX or even the JS fairly trivially, but they don't. There are many theories [*] as to why that is, but the empirical evidence is that the obfuscation is very effective at reducing spam dramatically, no matter how silly that seems. * Maybe it's too much low hanging fruit. Maybe they don't want to risk hitting honey-pot emails. Maybe anybody smart enough to obfustcate is too smart to fall for the stupid spam anyway. ... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
You could also use %XX in HEX on the mailto: On Tue, February 27, 2007 11:09 pm, Casey Chu wrote: > It works. =P I tested it. > > Try it here! =P > > http://themfund.com/snippets/test.php > > On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: >> I'm not sure with both of your questions. I'm too lazy to try. >> >> Untested: But to encode it, you would use >> >> preg_replace_callback('~([\d\w])~', create_function('$a', 'return >> "".ord($a[0]).";";'), $theEmail); >> >> Hopefully that works? >> >> On 2/27/07, John Taylor-Johnston >> <[EMAIL PROTECTED]> wrote: >> > How do I encode it? And would the href tag work? >> > >> > Casey Chu wrote: >> > > ^ So put that into a tag. >> > > >> > > On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: >> > >> Try using Javascript? Or use all entities? For example: >> > >> mailto:php-general@lists.php.net would turn into >> > >> mailto:php-general@lists.php.net >> > >> >> > >> >> > >> >> > >> >> > >> On 2/27/07, John Taylor-Johnston >> > >> <[EMAIL PROTECTED]> wrote: >> > >> > I need an anti-spam-spider measure for my site. Too many >> addresses are >> > >> > getting raked. In once instance, I created a flash page: >> > >> > http://erasethis.glquebec.org/English/contact.htm >> > >> > But I just don't have the time to create a flash image for >> every >> > >> single >> > >> > instance, most of which come from dynamically printed PHP >> pages from a >> > >> > MySQL database. >> > >> > >> > >> > Could I dynamically create a flash image, input the email and >> tell the >> > >> > flash image to mailto:[EMAIL PROTECTED] >> > >> > >> > >> > Do anyone have a solution? Does one already exist? >> > >> > >> > >> > My idea was to create a PHP script and output to a png. But I >> see many >> > >> > problems, including: >> > >> > >> > >> > 1) How do I avoid echoing the email address in the > href=""> tag? >> > >> > 2) How would I write a png that would be long and high >> enough? >> > >> > 3) How would the same script display the png? >> > >> > >> > >> > In short, I can't see far enough how to do this and avoid >> > >> spider-raking >> > >> > in the HTML or header the content of the image. >> > >> > >> > >> > Any advice, code or input would be appreciated, >> > >> > John >> > >> > >> > >> > > > >> > echo $??; >> > >> > >> > >> > ?>">> > >> > echo $??; >> > >> > >> > >> > ?>" width="???" height="???"> >> > >> > >> > >> > -- >> > >> > PHP General Mailing List (http://www.php.net/) >> > >> > To unsubscribe, visit: http://www.php.net/unsub.php >> > >> > >> > >> > >> > >> >> > > >> > >> > -- >> > PHP General Mailing List (http://www.php.net/) >> > To unsubscribe, visit: http://www.php.net/unsub.php >> > >> > >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
On Tue, February 27, 2007 10:22 pm, John Taylor-Johnston wrote: > I need an anti-spam-spider measure for my site. Too many addresses are > getting raked. In once instance, I created a flash page: > http://erasethis.glquebec.org/English/contact.htm > But I just don't have the time to create a flash image for every > single > instance, most of which come from dynamically printed PHP pages from a > MySQL database. > > Could I dynamically create a flash image, input the email and tell the > flash image to mailto:[EMAIL PROTECTED] > > Do anyone have a solution? Does one already exist? http://php.net/ming would let you do exactly that, assuming the Actionscript to send the email will work. > My idea was to create a PHP script and output to a png. But I see many > problems, including: > > 1) How do I avoid echoing the email address in the tag? > 2) How would I write a png that would be long and high enough? > 3) How would the same script display the png? You could "obfuscate" the address with html encoding, such as: @ -> @ in the HTML @ -> %40 in the URL I believe the scrapers/spammers are still not bothering to defeat this trivial exercise because they still get a million hits looking for plain old emails. > In short, I can't see far enough how to do this and avoid > spider-raking > in the HTML or header the content of the image. I would suspect that every email is tied to some database record, like an ID. Provide a FORM which has only the ID in it, and lookup the email, and send the email out yourself from your own server. Yes, you could end up sending a LOT of email. Or not, since you now control the sending with PHP and can refuse to send in whatever scenario you find unacceptable. For example, one of my sites does this but won't send more than 4 emails from any given IP address in one 24-hour period. So a scraper/spammer would need to alter their IP every 4 POST operations, which is really more work than they'll put into it. On a super busy server with millions of users or millions of potential recipients, this would probably be a big deal... On MOST websites, you'll essentially be playing postman for a couple legit emails a day, at most, and not having any problem with scrapers/spammers. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
Can I PHP generate a flash *.swf? How? If not how do I PHP generate a *.png or gif? Jochem Maas wrote: Stut wrote: Of course the best way is to use an image and don't link it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
On 2/28/07, tedd <[EMAIL PROTECTED]> wrote: At 11:22 PM -0500 2/27/07, John Taylor-Johnston wrote: >I need an anti-spam-spider measure for my site. Too many addresses >are getting raked. In once instance, I created a flash page: >http://erasethis.glquebec.org/English/contact.htm >But I just don't have the time to create a flash image for every >single instance, most of which come from dynamically printed PHP >pages from a MySQL database. > >Could I dynamically create a flash image, input the email and tell >the flash image to mailto:[EMAIL PROTECTED] > >Do anyone have a solution? Does one already exist? I agree with Stut that entities are the easiest for bots to handle. As for myself, I use javascript Enkoder -- you can Google it for a way to use it. As for an example of its use, please review: http://sperling.com/contact.php and inspect the source. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://automaticlabs.com/products/enkoderform/ -- http://www.web-buddha.co.uk
Re: [PHP] echo text - anti-spam-spider measure
At 11:22 PM -0500 2/27/07, John Taylor-Johnston wrote: I need an anti-spam-spider measure for my site. Too many addresses are getting raked. In once instance, I created a flash page: http://erasethis.glquebec.org/English/contact.htm But I just don't have the time to create a flash image for every single instance, most of which come from dynamically printed PHP pages from a MySQL database. Could I dynamically create a flash image, input the email and tell the flash image to mailto:[EMAIL PROTECTED] Do anyone have a solution? Does one already exist? I agree with Stut that entities are the easiest for bots to handle. As for myself, I use javascript Enkoder -- you can Google it for a way to use it. As for an example of its use, please review: http://sperling.com/contact.php and inspect the source. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
Stut wrote: > John Taylor-Johnston wrote: >> Neat, and thnaks. >> How spam-spider-proof is it? I will try this though. >> But I will also try it with "mailto:"; in entities as well. >> Thanks! >> John >> >> >> > href="mailto:me@somewhere.com";>me@somewhere.com >> >> > > Of all the possible methods, entities are the easiest for bots to > handle. They just need to decode the entities. in the past I found the following to be annoying enough for harvesters not to bother: function obsfucateString($str) { $ret = ''; for ($i=0;$i > More reliable methods involve using javascript to write out the mailto: > tag. Do it in several statements. But even then, some of the smarter > spiders will execute simple javascript like that. You can make it better > by using onload to execute the javascript which means the spider will > need to implement that, which I don't believe they do at the moment. > > Of course the best way is to use an image and don't link it. If it's > just a way for visitors to contact you, use a contact form. You don't > expose the email address and can control it a lot better. > > -Stut > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
John Taylor-Johnston wrote: Neat, and thnaks. How spam-spider-proof is it? I will try this though. But I will also try it with "mailto:"; in entities as well. Thanks! John href="mailto:me@somewhere.com";>me@somewhere.com Of all the possible methods, entities are the easiest for bots to handle. They just need to decode the entities. More reliable methods involve using javascript to write out the mailto: tag. Do it in several statements. But even then, some of the smarter spiders will execute simple javascript like that. You can make it better by using onload to execute the javascript which means the spider will need to implement that, which I don't believe they do at the moment. Of course the best way is to use an image and don't link it. If it's just a way for visitors to contact you, use a contact form. You don't expose the email address and can control it a lot better. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
Neat, and thnaks. How spam-spider-proof is it? I will try this though. But I will also try it with "mailto:"; in entities as well. Thanks! John mailto:me@somewhere.com";>me@somewhere.com Casey Chu wrote: It works. =P I tested it. Try it here! =P http://themfund.com/snippets/test.php On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: I'm not sure with both of your questions. I'm too lazy to try. Untested: But to encode it, you would use preg_replace_callback('~([\d\w])~', create_function('$a', 'return "".ord($a[0]).";";'), $theEmail); Hopefully that works? On 2/27/07, John Taylor-Johnston <[EMAIL PROTECTED]> wrote: > How do I encode it? And would the href tag work? > > Casey Chu wrote: > > ^ So put that into a tag. > > > > On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: > >> Try using Javascript? Or use all entities? For example: > >> mailto:php-general@lists.php.net would turn into > >> mailto:php-general@lists.php.net > >> > >> > >> > >> > >> On 2/27/07, John Taylor-Johnston > >> <[EMAIL PROTECTED]> wrote: > >> > I need an anti-spam-spider measure for my site. Too many addresses are > >> > getting raked. In once instance, I created a flash page: > >> > http://erasethis.glquebec.org/English/contact.htm > >> > But I just don't have the time to create a flash image for every > >> single > >> > instance, most of which come from dynamically printed PHP pages from a > >> > MySQL database. > >> > > >> > Could I dynamically create a flash image, input the email and tell the > >> > flash image to mailto:[EMAIL PROTECTED] > >> > > >> > Do anyone have a solution? Does one already exist? > >> > > >> > My idea was to create a PHP script and output to a png. But I see many > >> > problems, including: > >> > > >> > 1) How do I avoid echoing the email address in the tag? > >> > 2) How would I write a png that would be long and high enough? > >> > 3) How would the same script display the png? > >> > > >> > In short, I can't see far enough how to do this and avoid > >> spider-raking > >> > in the HTML or header the content of the image. > >> > > >> > Any advice, code or input would be appreciated, > >> > John > >> > > >> > >> > echo $??; > >> > > >> > ?>"> >> > echo $??; > >> > > >> > ?>" width="???" height="???"> > >> > > >> > -- > >> > PHP General Mailing List (http://www.php.net/) > >> > To unsubscribe, visit: http://www.php.net/unsub.php > >> > > >> > > >> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
Try using Javascript? Or use all entities? For example: mailto:php-general@lists.php.net would turn into mailto:php-general@lists.php.net On 2/27/07, John Taylor-Johnston <[EMAIL PROTECTED]> wrote: I need an anti-spam-spider measure for my site. Too many addresses are getting raked. In once instance, I created a flash page: http://erasethis.glquebec.org/English/contact.htm But I just don't have the time to create a flash image for every single instance, most of which come from dynamically printed PHP pages from a MySQL database. Could I dynamically create a flash image, input the email and tell the flash image to mailto:[EMAIL PROTECTED] Do anyone have a solution? Does one already exist? My idea was to create a PHP script and output to a png. But I see many problems, including: 1) How do I avoid echoing the email address in the tag? 2) How would I write a png that would be long and high enough? 3) How would the same script display the png? In short, I can't see far enough how to do this and avoid spider-raking in the HTML or header the content of the image. Any advice, code or input would be appreciated, John ">" width="???" height="???"> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
^ So put that into a tag. On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: Try using Javascript? Or use all entities? For example: mailto:php-general@lists.php.net would turn into mailto:php-general@lists.php.net On 2/27/07, John Taylor-Johnston <[EMAIL PROTECTED]> wrote: > I need an anti-spam-spider measure for my site. Too many addresses are > getting raked. In once instance, I created a flash page: > http://erasethis.glquebec.org/English/contact.htm > But I just don't have the time to create a flash image for every single > instance, most of which come from dynamically printed PHP pages from a > MySQL database. > > Could I dynamically create a flash image, input the email and tell the > flash image to mailto:[EMAIL PROTECTED] > > Do anyone have a solution? Does one already exist? > > My idea was to create a PHP script and output to a png. But I see many > problems, including: > > 1) How do I avoid echoing the email address in the tag? > 2) How would I write a png that would be long and high enough? > 3) How would the same script display the png? > > In short, I can't see far enough how to do this and avoid spider-raking > in the HTML or header the content of the image. > > Any advice, code or input would be appreciated, > John > > echo $??; > > ?>"> echo $??; > > ?>" width="???" height="???"> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo text - anti-spam-spider measure
I need an anti-spam-spider measure for my site. Too many addresses are getting raked. In once instance, I created a flash page: http://erasethis.glquebec.org/English/contact.htm But I just don't have the time to create a flash image for every single instance, most of which come from dynamically printed PHP pages from a MySQL database. Could I dynamically create a flash image, input the email and tell the flash image to mailto:[EMAIL PROTECTED] Do anyone have a solution? Does one already exist? My idea was to create a PHP script and output to a png. But I see many problems, including: 1) How do I avoid echoing the email address in the tag? 2) How would I write a png that would be long and high enough? 3) How would the same script display the png? In short, I can't see far enough how to do this and avoid spider-raking in the HTML or header the content of the image. Any advice, code or input would be appreciated, John ">" width="???" height="???"> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
It works. =P I tested it. Try it here! =P http://themfund.com/snippets/test.php On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: I'm not sure with both of your questions. I'm too lazy to try. Untested: But to encode it, you would use preg_replace_callback('~([\d\w])~', create_function('$a', 'return "".ord($a[0]).";";'), $theEmail); Hopefully that works? On 2/27/07, John Taylor-Johnston <[EMAIL PROTECTED]> wrote: > How do I encode it? And would the href tag work? > > Casey Chu wrote: > > ^ So put that into a tag. > > > > On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: > >> Try using Javascript? Or use all entities? For example: > >> mailto:php-general@lists.php.net would turn into > >> mailto:php-general@lists.php.net > >> > >> > >> > >> > >> On 2/27/07, John Taylor-Johnston > >> <[EMAIL PROTECTED]> wrote: > >> > I need an anti-spam-spider measure for my site. Too many addresses are > >> > getting raked. In once instance, I created a flash page: > >> > http://erasethis.glquebec.org/English/contact.htm > >> > But I just don't have the time to create a flash image for every > >> single > >> > instance, most of which come from dynamically printed PHP pages from a > >> > MySQL database. > >> > > >> > Could I dynamically create a flash image, input the email and tell the > >> > flash image to mailto:[EMAIL PROTECTED] > >> > > >> > Do anyone have a solution? Does one already exist? > >> > > >> > My idea was to create a PHP script and output to a png. But I see many > >> > problems, including: > >> > > >> > 1) How do I avoid echoing the email address in the tag? > >> > 2) How would I write a png that would be long and high enough? > >> > 3) How would the same script display the png? > >> > > >> > In short, I can't see far enough how to do this and avoid > >> spider-raking > >> > in the HTML or header the content of the image. > >> > > >> > Any advice, code or input would be appreciated, > >> > John > >> > > >> > >> > echo $??; > >> > > >> > ?>"> >> > echo $??; > >> > > >> > ?>" width="???" height="???"> > >> > > >> > -- > >> > PHP General Mailing List (http://www.php.net/) > >> > To unsubscribe, visit: http://www.php.net/unsub.php > >> > > >> > > >> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
I'm not sure with both of your questions. I'm too lazy to try. Untested: But to encode it, you would use preg_replace_callback('~([\d\w])~', create_function('$a', 'return "".ord($a[0]).";";'), $theEmail); Hopefully that works? On 2/27/07, John Taylor-Johnston <[EMAIL PROTECTED]> wrote: How do I encode it? And would the href tag work? Casey Chu wrote: > ^ So put that into a tag. > > On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: >> Try using Javascript? Or use all entities? For example: >> mailto:php-general@lists.php.net would turn into >> mailto:php-general@lists.php.net >> >> >> >> >> On 2/27/07, John Taylor-Johnston >> <[EMAIL PROTECTED]> wrote: >> > I need an anti-spam-spider measure for my site. Too many addresses are >> > getting raked. In once instance, I created a flash page: >> > http://erasethis.glquebec.org/English/contact.htm >> > But I just don't have the time to create a flash image for every >> single >> > instance, most of which come from dynamically printed PHP pages from a >> > MySQL database. >> > >> > Could I dynamically create a flash image, input the email and tell the >> > flash image to mailto:[EMAIL PROTECTED] >> > >> > Do anyone have a solution? Does one already exist? >> > >> > My idea was to create a PHP script and output to a png. But I see many >> > problems, including: >> > >> > 1) How do I avoid echoing the email address in the tag? >> > 2) How would I write a png that would be long and high enough? >> > 3) How would the same script display the png? >> > >> > In short, I can't see far enough how to do this and avoid >> spider-raking >> > in the HTML or header the content of the image. >> > >> > Any advice, code or input would be appreciated, >> > John >> > >> > > > echo $??; >> > >> > ?>">> > echo $??; >> > >> > ?>" width="???" height="???"> >> > >> > -- >> > PHP General Mailing List (http://www.php.net/) >> > To unsubscribe, visit: http://www.php.net/unsub.php >> > >> > >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo text - anti-spam-spider measure
How do I encode it? And would the href tag work? Casey Chu wrote: ^ So put that into a tag. On 2/27/07, Casey Chu <[EMAIL PROTECTED]> wrote: Try using Javascript? Or use all entities? For example: mailto:php-general@lists.php.net would turn into mailto:php-general@lists.php.net On 2/27/07, John Taylor-Johnston <[EMAIL PROTECTED]> wrote: > I need an anti-spam-spider measure for my site. Too many addresses are > getting raked. In once instance, I created a flash page: > http://erasethis.glquebec.org/English/contact.htm > But I just don't have the time to create a flash image for every single > instance, most of which come from dynamically printed PHP pages from a > MySQL database. > > Could I dynamically create a flash image, input the email and tell the > flash image to mailto:[EMAIL PROTECTED] > > Do anyone have a solution? Does one already exist? > > My idea was to create a PHP script and output to a png. But I see many > problems, including: > > 1) How do I avoid echoing the email address in the tag? > 2) How would I write a png that would be long and high enough? > 3) How would the same script display the png? > > In short, I can't see far enough how to do this and avoid spider-raking > in the HTML or header the content of the image. > > Any advice, code or input would be appreciated, > John > > echo $??; > > ?>"> echo $??; > > ?>" width="???" height="???"> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO
Fahad Pervaiz wrote: > ECHO is a language construct but still is there any work around to override > it or change its functionality??? if your willing to hack the php source then you can pretty much do whatever you want; that said there is no mechanism for overriding echo or any other language construct in the std php... there is runkit (http://php.net/runkit) but that doesn't seem to offer language construct overriding based on a quick glance. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO
Fahad Pervaiz wrote: ECHO is a language construct but still is there any work around to override it or change its functionality??? Nope. You're stuck with how it works now. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO
Why do you need to change its functionality? On 12/18/06, Fahad Pervaiz <[EMAIL PROTECTED]> wrote: ECHO is a language construct but still is there any work around to override it or change its functionality??? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ECHO
ECHO is a language construct but still is there any work around to override it or change its functionality???
Re: [PHP] ECHO $variable
thank you for schooling me :) i learn something new everyday! - Original Message - From: "Richard Lynch" <[EMAIL PROTECTED]> To: "benifactor" <[EMAIL PROTECTED]> Cc: Sent: Monday, October 09, 2006 11:02 AM Subject: Re: [PHP] ECHO $variable > On Mon, October 9, 2006 7:45 am, benifactor wrote: > > the way i posted worked fine with out either... he doesn't need to use > > these > > to format the way his output is displayed, he only needs to use the > > proper > > php syntax if i am correct. > > You were wrong, and you're still wrong. :-) > > Try it and see. > > http://php.net/htmlentities is the correct solution. > > htmlspecialchars only catches a tiny subset of what *might* be in the > string... So it will work if you can guarantee that only those > limited set of chars will ever be in there. > > -- > Some people have a "gift" link here. > Know what I want? > I want you to buy a CD from some starving artist. > http://cdbaby.com/browse/from/lynch > Yeah, I get a buck. So? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
On Mon, October 9, 2006 7:45 am, benifactor wrote: > the way i posted worked fine with out either... he doesn't need to use > these > to format the way his output is displayed, he only needs to use the > proper > php syntax if i am correct. You were wrong, and you're still wrong. :-) Try it and see. http://php.net/htmlentities is the correct solution. htmlspecialchars only catches a tiny subset of what *might* be in the string... So it will work if you can guarantee that only those limited set of chars will ever be in there. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
On Sun, October 8, 2006 1:39 am, Ron Piggott (PHP) wrote: > In one of my scripts I have > > value=" $saved_message_title;?>"> > > where > > $saved_message_title is 1 Peter 5:7 "Cast all your cares on Him for He > cares about you" > --- note the " > > When this is displayed on the screen $saved_message_title reads > > 1 Peter 5:7 > > I am assuming the " closes the value= Yup. Use "View Souce" in your browser to confirm that. > How may I echo this to the screen and have the full text be displayed, > not just 1 Peter 5:7 ? *ALL* data going to HTML should have http://php.net/htmlentities called on it. This will convert " to " so that it is properly escaped for HTML output. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
On 10/9/06, benifactor <[EMAIL PROTECTED]> wrote: the way i posted worked fine with out either... he doesn't need to use these to format the way his output is displayed, he only needs to use the proper php syntax if i am correct. But what if the string is edited to contain single quotes as well? Then your solution breaks anyway... Like Chris said, you should be using htmlentities for output... John W - Original Message - From: "Penthexquadium" <[EMAIL PROTECTED]> To: Sent: Sunday, October 08, 2006 1:41 AM Subject: Re: [PHP] ECHO $variable > On Mon, 9 Oct 2006 00:23:00 -0700, "benifactor" <[EMAIL PROTECTED]> wrote: > > you should try this... > > > > $saved_message_title = '1 Peter 5:7 "Cast all your cares on Him for He > > cares about you"'; > > - Original Message - > > From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]> > > To: "PHP General" > > Sent: Saturday, October 07, 2006 11:39 PM > > Subject: [PHP] ECHO $variable > > > > > > > In one of my scripts I have > > > > > > > > > > > > where > > > > > > $saved_message_title is 1 Peter 5:7 "Cast all your cares on Him for He > > > cares about you" > > > --- note the " > > > > > > When this is displayed on the screen $saved_message_title reads > > > > > > 1 Peter 5:7 > > > > > > I am assuming the " closes the value= > > > > > > How may I echo this to the screen and have the full text be displayed, > > > not just 1 Peter 5:7 ? > > > > > > Ron > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > His problem is in HTML, not PHP. > > Uses htmlspecialchars() or htmlentities() to convert special characters > to HTML entities. The double quote will becomes """ so that it can > be display correctly. > > -- > Sorry for my poor English. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
Ron Piggott wrote: > When this is displayed on the screen $saved_message_title reads > > 1 Peter 5:7 > > I am assuming the " closes the value= > > How may I echo this to the screen and have the full text be > displayed, not just 1 Peter 5:7 ? http://php.net/htmlentities You should really be using this for all output. Hope that helps. Chris -- Chris Shiflett http://shiflett.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
the way i posted worked fine with out either... he doesn't need to use these to format the way his output is displayed, he only needs to use the proper php syntax if i am correct. - Original Message - From: "Penthexquadium" <[EMAIL PROTECTED]> To: Sent: Sunday, October 08, 2006 1:41 AM Subject: Re: [PHP] ECHO $variable > On Mon, 9 Oct 2006 00:23:00 -0700, "benifactor" <[EMAIL PROTECTED]> wrote: > > you should try this... > > > > $saved_message_title = '1 Peter 5:7 "Cast all your cares on Him for He > > cares about you"'; > > - Original Message - > > From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]> > > To: "PHP General" > > Sent: Saturday, October 07, 2006 11:39 PM > > Subject: [PHP] ECHO $variable > > > > > > > In one of my scripts I have > > > > > > > > > > > > where > > > > > > $saved_message_title is 1 Peter 5:7 "Cast all your cares on Him for He > > > cares about you" > > > --- note the " > > > > > > When this is displayed on the screen $saved_message_title reads > > > > > > 1 Peter 5:7 > > > > > > I am assuming the " closes the value= > > > > > > How may I echo this to the screen and have the full text be displayed, > > > not just 1 Peter 5:7 ? > > > > > > Ron > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > His problem is in HTML, not PHP. > > Uses htmlspecialchars() or htmlentities() to convert special characters > to HTML entities. The double quote will becomes """ so that it can > be display correctly. > > -- > Sorry for my poor English. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
On Mon, 9 Oct 2006 00:23:00 -0700, "benifactor" <[EMAIL PROTECTED]> wrote: > you should try this... > > $saved_message_title = '1 Peter 5:7 "Cast all your cares on Him for He > cares about you"'; > - Original Message - > From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]> > To: "PHP General" > Sent: Saturday, October 07, 2006 11:39 PM > Subject: [PHP] ECHO $variable > > > > In one of my scripts I have > > > > > > > > where > > > > $saved_message_title is 1 Peter 5:7 "Cast all your cares on Him for He > > cares about you" > > --- note the " > > > > When this is displayed on the screen $saved_message_title reads > > > > 1 Peter 5:7 > > > > I am assuming the " closes the value= > > > > How may I echo this to the screen and have the full text be displayed, > > not just 1 Peter 5:7 ? > > > > Ron > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php His problem is in HTML, not PHP. Uses htmlspecialchars() or htmlentities() to convert special characters to HTML entities. The double quote will becomes """ so that it can be display correctly. -- Sorry for my poor English. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
you should try this... $saved_message_title = '1 Peter 5:7 "Cast all your cares on Him for He cares about you"'; - Original Message - From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]> To: "PHP General" Sent: Saturday, October 07, 2006 11:39 PM Subject: [PHP] ECHO $variable > In one of my scripts I have > > > > where > > $saved_message_title is 1 Peter 5:7 "Cast all your cares on Him for He > cares about you" > --- note the " > > When this is displayed on the screen $saved_message_title reads > > 1 Peter 5:7 > > I am assuming the " closes the value= > > How may I echo this to the screen and have the full text be displayed, > not just 1 Peter 5:7 ? > > Ron > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ECHO $variable
In one of my scripts I have where $saved_message_title is 1 Peter 5:7 "Cast all your cares on Him for He cares about you" --- note the " When this is displayed on the screen $saved_message_title reads 1 Peter 5:7 I am assuming the " closes the value= How may I echo this to the screen and have the full text be displayed, not just 1 Peter 5:7 ? Ron
Re: [PHP] Echo a value from an arrays position
Dave Goodchild wrote: This may clarify - in php, integer and associate arrays are created arbitrarily, ie keys can be numbers or strings. So, either create an array like this: array('1' => 'first element', '2' => 'second element'); if I'm not mistaken the above example will result in an array with 2 *numeric* keys because any strings keys that php that are numeric (according to the logic of is_numeric()) will be seen as numeric keys. so the above example could lead to even more confusion! and call by the key! On 04/05/06, Jonas Rosling <[EMAIL PROTECTED]> wrote: Is there any way to call for an element value in an array by the position? Like position 2 in the array and not the key name. // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php