php-general Digest 1 Sep 2011 12:02:52 -0000 Issue 7465

Topics (messages 314686 through 314701):

Mysqli error handling
        314686 by: Robert Williams

Re: Code should be selv-maintaining!
        314687 by: Tedd Sperling
        314689 by: Paul M Foster
        314690 by: Ross McKay
        314691 by: Robert Cummings
        314692 by: George Langley
        314693 by: Robert Cummings
        314694 by: Ross McKay
        314695 by: Robert Cummings
        314700 by: Richard Quadling

Re: [EasyPHP] How to export and import `alias` from previous version of EasyPHP?
        314688 by: Nam Gi VU

Re: Bug #51739 tricky string to float conversion
        314696 by: magic-php.damage.devloop.de
        314697 by: Simon J Welsh
        314698 by: magic-php.damage.devloop.de
        314699 by: Florian Lemaitre

PHP/ Soap issue
        314701 by: richard gray

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Okay, so I've finally got an opportunity to start converting our code to
use Mysqli instead of the old mysql_* functions. Mysqli is new to me, but
I thought things were going well until the first time I tried to run a
query with a syntax error in it, and it threw up a PHP warning. Being that
Mysqli is an OO API, I guess I assumed that any errors would simply
surface as exceptions, and indeed, I got an exception in this case. But I
also got a PHP warning containing the same information.

This is the first thing that strikes me as terribly wrong. I think any
API, OO or not, should never spit out errors/warnings/notices for routine
errors (like, in this case, an SQL syntax error). Rather, the
function/method should signal an error through a defined mechanism, such
as the return value (e.g., false on failure), or via an exception for
class methods. This philosophy jives well with my understand of the
direction of error handling in PHP, which is to use exceptions, rather
than errors/warnings/notices, for all the newer OOP APIs.

Secondly, I can't find a good way to handle these warnings. We do all
development with error handling set to E_STRICT | E_ALL, and our general
policy is that no such errors should be generated. This behavior by Mysqli
means that we effectively need to catch SQL problems in both our error
handlers and in our exception handling. I recognize that we could just use
suppression, but that's, well, nasty.

Digging a bit more, I found mysqli_report(). This looks pretty good, but I
find it odd that 1) it's a procedural-only function that controls an OO
API, and 2), it takes affect for the entire request, which effectively
means it has to be set up right for each database access rather than just
once per database instance. I suspect this relates to the underlying
implementation, but it's still quite the letdown.

Is there something I'm missing in all this, or is really as clunky as it
seems? What have those of you with more Mysqli experience found to work
well as a good error-handling pattern when working with it?


--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/







Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

--- End Message ---
--- Begin Message ---
On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote:

> On 11-08-30 11:36 AM, Richard Quadling wrote:
>> On 30 August 2011 15:04, Tedd Sperling<tedd.sperl...@gmail.com>  wrote:
>>> To all:
>>> 
>>> I prefer the Whitesmiths style:
>>> 
>>> http://rebel.lcc.edu/sperlt/citw229/brace-styles.php
>>> 
>>> But "style" is really up to the individual -- what works best for you is 
>>> the "best" (unless it's a team effort or the clients demand).
>>> 
>>> Cheers,
>>> 
>>> tedd
>> 
>> At last!!!! Someone's code I could read without having to reformat it
>> every bloody time!!!
>> 
>> http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style
> 
> You're just saying that so Tedd will be your friend!! Come now, let's be 
> honest with everyone... Whitesmith's is UUUUUUUUHHHH-GLEE! ;)
> 
> Cheers,
> Rob.

No, not indenting braces is BBBBUUUUTTTTT UUUUUUUUUUUUGGGGGGGGLLLLLYYYYYY.

Make things uniform -- a condition followed by indented code located between 
equally indented braces makes sense to me. How people read other code styles is 
a mystery to me.

Cheers,

tedd


_____________________
t...@sperling.com
http://sperling.com







--- End Message ---
--- Begin Message ---
On Wed, Aug 31, 2011 at 08:20:14PM -0400, Tedd Sperling wrote:

> On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote:
> 
> > On 11-08-30 11:36 AM, Richard Quadling wrote:
> >> On 30 August 2011 15:04, Tedd Sperling<tedd.sperl...@gmail.com>
> >> wrote:
> >>> To all:
> >>> 
> >>> I prefer the Whitesmiths style:
> >>> 
> >>> http://rebel.lcc.edu/sperlt/citw229/brace-styles.php
> >>> 
> >>> But "style" is really up to the individual -- what works best for
> >>> you is the "best" (unless it's a team effort or the clients
> >>> demand).
> >>> 
> >>> Cheers,
> >>> 
> >>> tedd
> >> 
> >> At last!!!! Someone's code I could read without having to reformat
> >> it every bloody time!!!
> >> 
> >> http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style
> > 
> > You're just saying that so Tedd will be your friend!! Come now,
> > let's be honest with everyone... Whitesmith's is UUUUUUUUHHHH-GLEE!
> > ;)
> > 
> > Cheers, Rob.
> 
> No, not indenting braces is BBBBUUUUTTTTT
> UUUUUUUUUUUUGGGGGGGGLLLLLYYYYYY.
> 
> Make things uniform -- a condition followed by indented code located
> between equally indented braces makes sense to me. 
> How people read
> other code styles is a mystery to me.

Indeed it is a mystery, a religious one. The way we do it is because we
finally broke through the clouds of earthly obfuscation to comprehend
the blinding truth that is K&R. Amen.

(Nah, it wasn't Kool-Aid. Tasted more like a cross between RC Cola and
Dr Pepper.) ;-}

Paul


-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

--- End Message ---
--- Begin Message ---
On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote:

>I prefer the Whitesmiths style:
>
>http://rebel.lcc.edu/sperlt/citw229/brace-styles.php
>
>But "style" is really up to the individual -- what works best for you 
>is the "best" (unless it's a team effort or the clients demand).

I note on your page that you prefer Whitesmiths (truly ugly!) style even
for JavaScript. I'd strongly recommend against that, and also Allman
style, due to semicolon insertion. e.g. (randomly selected from Google)

http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/
http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/

Sure, instances of the problem are minimal, but if you're in the habit
of Dangerous Open Brace Placement then you just might fall afoul of it.

Besides, my editor (Geany) folds code mostly neatly with K&R :)
-- 
Ross McKay, Toronto, NSW Australia
"Let the laddie play wi the knife - he'll learn"
- The Wee Book of Calvin

--- End Message ---
--- Begin Message ---
On 11-08-31 08:20 PM, Tedd Sperling wrote:
On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote:

On 11-08-30 11:36 AM, Richard Quadling wrote:
On 30 August 2011 15:04, Tedd Sperling<tedd.sperl...@gmail.com>   wrote:
To all:

I prefer the Whitesmiths style:

http://rebel.lcc.edu/sperlt/citw229/brace-styles.php

But "style" is really up to the individual -- what works best for you is the 
"best" (unless it's a team effort or the clients demand).

Cheers,

tedd

At last!!!! Someone's code I could read without having to reformat it
every bloody time!!!

http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style

You're just saying that so Tedd will be your friend!! Come now, let's be honest 
with everyone... Whitesmith's is UUUUUUUUHHHH-GLEE! ;)

Cheers,
Rob.

No, not indenting braces is BBBBUUUUTTTTT UUUUUUUUUUUUGGGGGGGGLLLLLYYYYYY.

Make things uniform -- a condition followed by indented code located between 
equally indented braces makes sense to me. How people read other code styles is 
a mystery to me.

Come now Tedd! It's only Thursday and yet you jest so!!

:)

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.

--- End Message ---
--- Begin Message ---
On 2011-08-31, at 11:44 PM, Ross McKay wrote:

> On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote:
> 
>> I prefer the Whitesmiths style:
>> 
>> http://rebel.lcc.edu/sperlt/citw229/brace-styles.php
>> 
>> But "style" is really up to the individual -- what works best for you 
>> is the "best" (unless it's a team effort or the clients demand).
> 
> I note on your page that you prefer Whitesmiths (truly ugly!) style even
> for JavaScript. I'd strongly recommend against that, and also Allman
> style, due to semicolon insertion. e.g. (randomly selected from Google)
> 
> http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/
> http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/
> 
> Sure, instances of the problem are minimal, but if you're in the habit
> of Dangerous Open Brace Placement then you just might fall afoul of it.
> 
> Besides, my editor (Geany) folds code mostly neatly with K&R :)
-----------
        FWIW, am working my way through an O'Reilly book (HTML5 Canvas) right 
now and they appear to use The One True Brace Style in their code examples.
        Not religious about it, but it does help me know which code I wrote and 
what was touched by someone else!

George

--- End Message ---
--- Begin Message ---
On 11-09-01 01:44 AM, Ross McKay wrote:
On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote:

I prefer the Whitesmiths style:

http://rebel.lcc.edu/sperlt/citw229/brace-styles.php

But "style" is really up to the individual -- what works best for you
is the "best" (unless it's a team effort or the clients demand).

I note on your page that you prefer Whitesmiths (truly ugly!) style even
for JavaScript. I'd strongly recommend against that, and also Allman
style, due to semicolon insertion. e.g. (randomly selected from Google)

http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/
http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/

Sure, instances of the problem are minimal, but if you're in the habit
of Dangerous Open Brace Placement then you just might fall afoul of it.

Besides, my editor (Geany) folds code mostly neatly with K&R :)

That's because JavaScript is broken in some ways. As much as I like JavaScript, some parts of the language were thrown together by flinging crap at a fan and seeing what sticks to the wall... this being a prime example.

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.

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:

>That's because JavaScript is broken in some ways. As much as I like 
>JavaScript, some parts of the language were thrown together by flinging 
>crap at a fan and seeing what sticks to the wall... this being a prime 
>example.

Sounds a lot like PHP :) which I must add I love dearly, though it
certainly resembles your remark much more closely than JavaScript.

But on-topic, novices using a coding style and feeling their way around
a new language would be better served by the 1TB style than anything
that easily allows statement insertion (either by them, or by silly
language defects like JavaScript's semicolon insertion). 
-- 
Ross McKay, Toronto, NSW Australia
"Hold very tight please! Ting! Ting!" - Flanders and Swann

--- End Message ---
--- Begin Message ---
On 11-09-01 02:39 AM, Ross McKay wrote:
Robert Cummings wrote:

That's because JavaScript is broken in some ways. As much as I like
JavaScript, some parts of the language were thrown together by flinging
crap at a fan and seeing what sticks to the wall... this being a prime
example.

Sounds a lot like PHP :) which I must add I love dearly, though it
certainly resembles your remark much more closely than JavaScript.

But on-topic, novices using a coding style and feeling their way around
a new language would be better served by the 1TB style than anything
that easily allows statement insertion (either by them, or by silly
language defects like JavaScript's semicolon insertion).

Oh for sure, it's necessary that novices have something towards which they can evolve. If they start with Allman's then how could they improve their brace style >:)

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.

--- End Message ---
--- Begin Message ---
On 30 August 2011 23:25, Richard Quadling <rquadl...@gmail.com> wrote:
> On 30 August 2011 20:09, Robert Cummings <rob...@interjinn.com> wrote:
>> You're just saying that so Tedd will be your friend!! Come now, let's be
>> honest with everyone... Whitesmith's is UUUUUUUUHHHH-GLEE! ;)
>
> Beauty is in the eye of the beholder.

So I think we've all established that Whitesmith's is the way to go,
but what about markup languages?

Take our own lovely PHPDocumentation.

Here, in the main, we have all subordinate elements starting on their
own line, indented.

Is there really any other way that would make sense?


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--- End Message ---
--- Begin Message ---
Dear Danial,

I saw some update on EasyPHP via this group so I just thought to receive
support as well as such advertisement.
I'm sorry to "spam" this group.

Regards.

On Mon, Aug 29, 2011 at 7:26 PM, Daniel Brown <danbr...@php.net> wrote:

> On Sun, Aug 28, 2011 at 07:10, EasyPHP <easyphpdot...@gmail.com> wrote:
> > Hi
> >
> > Open your old conf_files/httpd.conf, copy the end of the file (between
> > #alias) and paste it in the new one.
> > Restart the servers. That's it!
>
>     Please keep EasyPHP-specific support requests off this list, and
> on a list, forum, or other support channel exclusively for that
> product.  It is a derivative of PHP, but it unrelated and should not
> be discussed here.
>
>    Thanks.
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Nam

--- End Message ---
--- Begin Message ---
Am Mittwoch, 31. August 2011, 20:48:37 schrieb Shawn McKenzie:
> On 08/31/2011 09:03 AM, magic-...@damage.devloop.de wrote:
> > Hi,
> > I have opend Bug #51739 in 2010. It was closed as bogus before my last
> > question was answered. It would be fine to know what you think about
> > that bug.
> > In short:
> > var_dump((float)"8315e839da08e2a7afe6dd12ec58245d");
> > results in float(INF)
> > This is because "8315" is treated as base and
> > "e839da08e2a7afe6dd12ec58245d" is treated as an exponent. My hint that
> > "e839da08e2a7afe6dd12ec58245d" is not a valid exponent was not answered.
> > What do you think about?
> > cheers
> > Daniel
> 
> The cast to float is truncating the invalid characters and since your
> string contains a float that is INF (8315e839) before the truncation at
> the "d", then it returns INF.  Makes perfect sense.

This is what drives me crazy.

If I use a string in PHP I don't want PHP to cut this string. Either it uses 
this string as it is or it gives me an error/warning/false (what ever...). But 
silently(!!!) using a small piece of a string is not understandable.

cheers
Daniel

--- End Message ---
--- Begin Message ---
On 1/09/2011, at 9:53 AM, magic-...@damage.devloop.de wrote:

> Am Mittwoch, 31. August 2011, 20:48:37 schrieb Shawn McKenzie:
>> On 08/31/2011 09:03 AM, magic-...@damage.devloop.de wrote:
>>> Hi,
>>> I have opend Bug #51739 in 2010. It was closed as bogus before my last
>>> question was answered. It would be fine to know what you think about
>>> that bug.
>>> In short:
>>> var_dump((float)"8315e839da08e2a7afe6dd12ec58245d");
>>> results in float(INF)
>>> This is because "8315" is treated as base and
>>> "e839da08e2a7afe6dd12ec58245d" is treated as an exponent. My hint that
>>> "e839da08e2a7afe6dd12ec58245d" is not a valid exponent was not answered.
>>> What do you think about?
>>> cheers
>>> Daniel
>> 
>> The cast to float is truncating the invalid characters and since your
>> string contains a float that is INF (8315e839) before the truncation at
>> the "d", then it returns INF.  Makes perfect sense.
> 
> This is what drives me crazy.
> 
> If I use a string in PHP I don't want PHP to cut this string. Either it uses 
> this string as it is or it gives me an error/warning/false (what ever...). 
> But 
> silently(!!!) using a small piece of a string is not understandable.
> 
> cheers
> Daniel

The manual clearly states this is how a string is converted into a number: 
http://php.net/manual/en/language.types.string.php#language.types.string.conversion

"The value is given by the initial portion of the string. If the string starts 
with valid numeric data, this will be the value used. Otherwise, the value will 
be 0 (zero). Valid numeric data is an optional sign, followed by one or more 
digits (optionally containing a decimal point), followed by an optional 
exponent. The exponent is an 'e' or 'E' followed by one or more digits."

If you don't want the string turned into a number using the documented method, 
don't use it as one.
---
Simon Welsh
Admin of http://simon.geek.nz/


--- End Message ---
--- Begin Message --- Simon J Welsh writes:
On 1/09/2011, at 9:53 AM, magic-...@damage.devloop.de wrote:
Am Mittwoch, 31. August 2011, 20:48:37 schrieb Shawn McKenzie:
On 08/31/2011 09:03 AM, magic-...@damage.devloop.de wrote:
var_dump((float)"8315e839da08e2a7afe6dd12ec58245d");
results in float(INF)

The cast to float is truncating the invalid characters and since your
string contains a float that is INF (8315e839) before the truncation at
the "d", then it returns INF.  Makes perfect sense.

If I use a string in PHP I don't want PHP to cut this string. Either it uses this string as it is or it gives me an error/warning/false (what ever...). But silently(!!!) using a small piece of a string is not understandable.

The manual clearly states this is how a string is converted into a number: http://php.net/manual/en/language.types.string.php#language.types.string.conversion "The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). Valid numeric data is an optional sign, followed by one or more digits (optionally containing a decimal point), followed by an optional exponent. The exponent is an 'e' or 'E' followed by one or more digits."
If you don't want the string turned into a number using the documented method, 
don't use it as one.

Ok, then let's discuss the documented behavior ;-) Do you (not the document) really like this behavior? I mean if I am the only one wondering about that behavior it is ok for me. I just want to help PHP.
cheers
Daniel

--- End Message ---
--- Begin Message ---
Le 01/09/2011 10:43, magic-...@damage.devloop.de a écrit :
Simon J Welsh writes:
On 1/09/2011, at 9:53 AM, magic-...@damage.devloop.de wrote:
Am Mittwoch, 31. August 2011, 20:48:37 schrieb Shawn McKenzie:
On 08/31/2011 09:03 AM, magic-...@damage.devloop.de wrote:
var_dump((float)"8315e839da08e2a7afe6dd12ec58245d");
results in float(INF)

The cast to float is truncating the invalid characters and since your
string contains a float that is INF (8315e839) before the truncation at
the "d", then it returns INF.  Makes perfect sense.

If I use a string in PHP I don't want PHP to cut this string. Either it uses this string as it is or it gives me an error/warning/false (what ever...). But silently(!!!) using a small piece of a string is not understandable.

The manual clearly states this is how a string is converted into a number: http://php.net/manual/en/language.types.string.php#language.types.string.conversion "The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). Valid numeric data is an optional sign, followed by one or more digits (optionally containing a decimal point), followed by an optional exponent. The exponent is an 'e' or 'E' followed by one or more digits." If you don't want the string turned into a number using the documented method, don't use it as one.

Ok, then let's discuss the documented behavior ;-)
Do you (not the document) really like this behavior? I mean if I am the only one wondering about that behavior it is ok for me. I just want to help PHP.
cheers
Daniel

No professional programmer would like this kind of behavior.
But PHP want to be accessible for newbies so we have to deal with that.
Hope this will be fixed in the next generation...



--- End Message ---
--- Begin Message --- I am hoping there's a SOAP expert on the list as this is driving me mad and Google doesn't come up with much help ...

I am trying to build a fairly simple web service in SOAP -- the client sends a string SKU to query a product catalogue database and receives product pricing data - I am using a WSDL file which validates OK ... anyway I keep getting this error:-

SOAP-ERROR: Encoding: object has no 'name' property

The PHP code is below:-

$client = new SoapClient('http://example.com/catalogue.wsdl',array('trace' => 1,'exceptions' => 0));
$sku = '12345';
$client->getProduct($sku);

I can post the wsdl file contents if necessary.

Hoping someone can help point me in the right direction!
TIA
Rich

--- End Message ---

Reply via email to