php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67977 Is it the expected behaviour?
Submitted: 2014-09-08 11:32 UTC Modified: 2014-09-08 11:53 UTC
From: admin at mvpro dot net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.5.16 OS: Linux Debian Wheezy x64
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: admin at mvpro dot net
New email:
PHP Version: OS:

 

 [2014-09-08 11:32 UTC] admin at mvpro dot net
Description:
------------
Hi.


I have a question - is it the expected behaviour that lines like

strtolower($str);

Do not equals to

$str = strtolower($str);

?

The second line is correct and works fine, but first - is not. No errors produced, but also it just does not work :) $str most likely is being lowercased, but string $str stay untouched. The same is with other functions like

wordwrap($text, 20, "<br />\n");

Do not equals to

$newtext = wordwrap($text, 20, "<br />\n");



In all cases i expect, that action will be performed and string changes. However it does not happen.


Thanks in advance.

Test script:
---------------
<?php
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtolower($str);
echo $str . PHP_EOL; // Prints mary had a little lamb and she loved it so
echo 'It works fine (all symbols are in lowercase)' . PHP_EOL;
?>
<?php
$str2 = "Mary Had A Little Lamb and She LOVED It So";
strtolower($str2);
echo $str2 . PHP_EOL; // Prints Mary Had A Little Lamb and She LOVED It So
echo 'It does not work (string is the same)' . PHP_EOL;
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-08 11:53 UTC] fa@php.net
-Status: Open +Status: Not a bug
 [2014-09-08 11:53 UTC] fa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Yes, hardly any (if any at all) of the string functions directly manipulate on the argument(s) given. They all return a modified copy of the string, as indicated by the "Return Values" section of the manual: http://php.net/strtolower
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 09:00:02 2026 UTC