Doc #79367 [NEW]: Undocumented behavior: Pass-by-ref arguments do not have to be initialized
From: mwolffhh at gmail dot com
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Undocumented behavior: Pass-by-ref arguments do not have to be initialized
Description:
------------
---
From manual page: https://php.net/language.references.pass
---
Usually, you must define a variable before it is used, otherwise PHP
will produce a notice.
When an argument defined as pass-by-reference though, defining the
variable before using it is no longer neccessary.
This is not mentioned in the pass-by-ref docs, nor in the function
argument docs:
https://www.php.net/manual/en/functions.arguments.php#functions.arguments.by-reference
Test script:
---------------
function output($s) {
echo $s;
}
output($a); // => PHP emits notice, "Undefined variable: a"
$a = "Test";
output($a); // => outputs "Test"
function outputByRef(&$s) {
echo $s;
}
outputByRef($a); // => no output, no notice
$a = "Test";
outputByRef($a); // => outputs "Test"
--
Edit bug report at https://bugs.php.net/bug.php?id=79367&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79367&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79367&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79367&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79367&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79367&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79367&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79367&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79367&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79367&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79367&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79367&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79367&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79367&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79367&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79367&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79367&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79367&r=mysqlcfg
Thread (2 messages)
- mwolffhh at gmail dot com