php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12930 request for &&= and ||= operators
Submitted: 2001-08-23 12:40 UTC Modified: 2010-12-29 12:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: pgl at instinct dot org Assigned: jani (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.6 OS: FreeBSD
Private report: No CVE-ID: None
 [2001-08-23 12:40 UTC] pgl at instinct dot org
Just a feature request for &&= and ||= operators as shortcuts for the logical equivalent of "$var && $var = 'val'".

eg:

<?
$a = '';
$a ||= "default";
print $a;
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-27 16:02 UTC] jimw@php.net
because && and || always return boolean values, this wouldn't do what you want. (and suggestions to make && and || be value-preserving instead of returning booleans has been shot down already.)
 [2010-12-29 12:22 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem -Assigned To: +Assigned To: jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC