php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63418 intval/strval pass-by-reference
Submitted: 2012-11-02 08:03 UTC Modified: 2012-11-03 04:28 UTC
From: ilyane at list dot ru Assigned:
Status: Wont fix Package: *General Issues
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ilyane at list dot ru
New email:
PHP Version: OS:

 

 [2012-11-02 08:03 UTC] ilyane at list dot ru
Description:
------------
---
From manual page: http://www.php.net/function.intval
---

Why not to add pass-by-reference option?

That would be such a beautiful thing:

intval(&$var);
strval(&$var);

and so on...

Test script:
---------------
$var = "123";

intval(&$var);

var_dump($var); //int(123)

Expected result:
----------------
int(123)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-03 00:37 UTC] mail+php at requinix dot net
Call-time pass-by-reference has been explicitly removed from 5.4 and had a warning 
in 5.3. You should not be using it at all.

If you don't want an assignment then use typecasting: var_dump( (int)$var )
 [2012-11-03 04:28 UTC] laruence@php.net
-Status: Open +Status: Wont fix
 [2012-11-03 04:28 UTC] laruence@php.net
previous comment explained it clearly
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 10 13:01:34 2025 UTC