Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58158 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3485 invoked from network); 27 Feb 2012 17:07:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2012 17:07:09 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:53735] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/3F-40985-B38BB4F4 for ; Mon, 27 Feb 2012 12:07:07 -0500 Received: by qaui11 with SMTP id i11so1167425qau.8 for ; Mon, 27 Feb 2012 09:07:04 -0800 (PST) Received-SPF: pass (google.com: domain of tyra3l@gmail.com designates 10.224.178.136 as permitted sender) client-ip=10.224.178.136; Authentication-Results: mr.google.com; spf=pass (google.com: domain of tyra3l@gmail.com designates 10.224.178.136 as permitted sender) smtp.mail=tyra3l@gmail.com; dkim=pass header.i=tyra3l@gmail.com Received: from mr.google.com ([10.224.178.136]) by 10.224.178.136 with SMTP id bm8mr12308786qab.19.1330362424757 (num_hops = 1); Mon, 27 Feb 2012 09:07:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=sF5AAJpUCEcZpPBaJHqmXq9H28pv0rbPA1pS5ube89Q=; b=MuaOIACd2seSjpSFRXLD4zqTv4Vb/boWtO2gHiuEiO3HnhrVNXb2PhEH14FblfQCZu FC60PyMQ+R5AY5QkmFeLBigxfljlX9VZsjBE5uVhrYSG3cDAPtqdD574uEXJu3rCPxtg 0vz03imzwKUwt+aVOxmZgDoVX3Yxv6+CLD82g= MIME-Version: 1.0 Received: by 10.224.178.136 with SMTP id bm8mr10345393qab.19.1330362424675; Mon, 27 Feb 2012 09:07:04 -0800 (PST) Received: by 10.229.30.205 with HTTP; Mon, 27 Feb 2012 09:07:04 -0800 (PST) In-Reply-To: <4F4BB59F.1040708@gmail.com> References: <1330357150.2159.30.camel@guybrush> <4F4BB59F.1040708@gmail.com> Date: Mon, 27 Feb 2012 18:07:04 +0100 Message-ID: To: =?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?= Cc: Paul Dragoonis , =?UTF-8?Q?Johannes_Schl=C3=BCter?= , Michael Morris , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=20cf303b38adbecbb204b9f523db Subject: Re: [PHP-DEV] Scalar type hinting From: tyra3l@gmail.com (Ferenc Kovacs) --20cf303b38adbecbb204b9f523db Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > > > Now strings. There are two different kinds of strings. > The first one $age =3D $_POST['age'] is the kind of string that you want = to > treat as a number. And that's fine. > > But you also have $name =3D $_POST['name'] // 'John Doe' which is wrong > to treat as a the same as $age. > > php doesn't have the necessary information to tell whether your input variable is a number, or only looks like a number. how would you define what is an int? what type would the following input variables have? - "1" - "1.1" - "1.0" - ".5" - "0777" I think it is better to populate everything as string, and let the application developer to parse the inputs as he knows what should they represent. Btw. there was a discussion about raising a warning (somebody even suggested creating an E_TYPE level) when data loss occurs on a type juggling. I would support that, as people tend to be surprised when they realize the first time that 123 =3D=3D '123 apples' evaluates to true in php. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --20cf303b38adbecbb204b9f523db--