php-general Digest 13 Oct 2009 07:27:39 -0000 Issue 6388
Topics (messages 298871 through 298877):
Re: How do YOU set default function/method params?
298871 by: Stephan Ebelt
Re: exec() confused by a specially crafted string
298872 by: Eddie Drapkin
Re: Need unrounded precision
298873 by: Andrea Giammarchi
libphp5.so rebuild required?
298874 by: SAILESH KRISHNAMURTI, BLOOMBERG/ 731 LEXIN
How to bypass (pipe) curl_exec return value directly to a file?
298875 by: m.hasibuan
298877 by: Lars Torben Wilson
Re: Insult my code!
298876 by: Eric Bauman
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Mon, Oct 12, 2009 at 01:44:56PM +0100, David Otton wrote:
> 2009/10/12 Stephan Ebelt <[email protected]>:
>
> > as far as I understood/use it: I try to hardcode as many workable defaults
> > in
> > the vo class as possible (ie. see $subject in the example). Then I create
> > objects
> > by passing result records from the database (arrays) to the constructor.
> > That
> > either returns a object or crashes the application if something is wrong.
>
> > Optionally I can create objects without any passed-in parameter which will
> > give
> > one with only the defaults set. Depending on the class' definition those may
>
> Ok, I'm going to make a case against the use of default values
> hard-coded within the class here:
>
[...]
I skip a) and b) for now as I mostly agree and first like to clarify...
>
> c) You should store all your config options in the same place.
... that I do not use this approach for global program config options. If this
was the intent of the original question I may have mistaken it entirely.
(I actually use constants for all on-site configurations and all are defined
in one file, there aren't so many and they can't be modified at runtime (I
think)).
My primary objective for using VOs was to have very strict and clear
definitions for data structures inside the program. Passing loosely defined
arrays from function to function caused too many bugs in my code. Now things
crash much earlier and I get to know problems quicker.
(besides: phpdoc creates nice crosslinks that tell precisely what some
method needs, no long parameter lists but thats also straying off).
stephan
--- End Message ---
--- Begin Message ---
On Mon, Oct 12, 2009 at 2:10 PM, Soner Tari <[email protected]> wrote:
> On Mon, 2009-10-12 at 13:21 -0300, Jonathan Tapicer wrote:
>> Confirmed, it also happens to me on Linux, PHP version:
>>
>> PHP 5.2.4-2ubuntu5.7 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21
>> 2009 19:52:39)
>> Copyright (c) 1997-2007 The PHP Group
>> Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
>>
>> And adding a single character to the echoed string makes it work fine,
>> seems like a bug to me.
>
> Thanks, filed the bug report:
> http://bugs.php.net/bug.php?id=49847
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Confirmed (again) here:
PHP Version => 5.3.0
Build Date => Jul 1 2009 17:55:55
--- End Message ---
--- Begin Message ---
bitwise right shift is probably the fastest cast to int so far ... still in
many languages, intval is a function call
being a cast in both cases (int) is good as well ... bitwise, casting, works
with strings, arrays, boolean, whatever as well.
I don't think there is any difference in php, except when the integer is "too
big" ... but this was not the case, we had to deal with 1 to 10 :-)
Regards
> From: [email protected]
> To: [email protected]
> CC: [email protected]
> Date: Mon, 12 Oct 2009 11:33:10 -0500
> Subject: RE: [PHP] Need unrounded precision
>
> >> Hmmm... Didn't think about this, but % only works with int values
> >
> >it was just future prof precaution since this statement is false for many
> >other languages.
> >In few words I am not sure PHP6 does the same ... never mind so far
>
> Good to know. In that case, I would probably just use intval() instead of >>
> since it's clearer and bitwise shifts aren't necessarily integer only either.
>
> Jaime
>
_________________________________________________________________
Windows Live: Make it easier for your friends to see what you’re up to on
Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009
--- End Message ---
--- Begin Message ---
Hi, We are looking to upgrade php 5.2.1 to 5.2.8. Do we need to rebuild the
libphp5.so also to detect the new version of underlying php or will the same
old version of libphp5.so build for php 5.2.1, automatically detect a new
underlying php installation? thanks
--- End Message ---
--- Begin Message ---
Newbie question.
I need to download a very large amount of xml data from a site using CURL.
How to bypass (pipe) curl_exec return value directly to a file, without
using memory allocation?
set_time_limit(0);
$ch = curl_init($siteURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$mixed = curl_exec($ch);
How to set/pipe $mixed as a (disk) file, so that data returned by curl_exec
is directly saved to the disk-file, and not involving memory allocation?
Thank you.
-PHP 5
-Windows XP
--- End Message ---
--- Begin Message ---
2009/10/12 m.hasibuan <[email protected]>:
> Newbie question.
> I need to download a very large amount of xml data from a site using CURL.
>
> How to bypass (pipe) curl_exec return value directly to a file, without
> using memory allocation?
>
> set_time_limit(0);
> $ch = curl_init($siteURL);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> $mixed = curl_exec($ch);
>
> How to set/pipe $mixed as a (disk) file, so that data returned by curl_exec
> is directly saved to the disk-file, and not involving memory allocation?
>
> Thank you.
Use the CURLOPT_FILE option to set the output to write to the file
handle given by the option's value (which must be a writable file
handle). For instance:
$ch = curl_init($url);
$fp = fopen('/tmp/curl.out', 'w');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
Error checking etc. is of course left up to you. :)
Good luck,
Torben
--- End Message ---
--- Begin Message ---
On 12/10/2009 9:21 PM, David Otton wrote:
2009/10/11 Eric Bauman<[email protected]>:
As before, please feel free to insult my code. ;-) Any and all feedback is
of course most appreciated.
I know you're more concerned with structure, but your checkInt()
method is arguably buggy/has an un-noted assumption. It accepts ints
formatted as ints and strings, but not floats:
*sigh* sometimes I really wish PHP allowed one to be a bit more
heavy-handed with types (optional real type hinting would be nice).
I guess I only ever worried about string (from DB) and int (internal
call) as in my specific use I would never be passing a float.
You make an excellent point however; I suppose in the interests of
completeness, forward compatibility etc. I should take into account more
possibilities. Perhaps I should just throw an exception in deposit()
etc. if the argument isn't int and worry about converting elsewhere.
Also thanks for the sample TestCase code! I've never really thought
about unit testing in PHP, despite doing so in Java etc. Reading about
PHPUnit brought me on to phpUnderControl - interesting stuff!
Best regards,
Eric
--- End Message ---