php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #8326 ucfirst() has no effect if input is ALL CAPITALIZED
Submitted: 2000-12-19 20:55 UTC Modified: 2001-01-10 02:03 UTC
From: vitaliyf at gameaholic dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.3pl1 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vitaliyf at gameaholic dot com
New email:
PHP Version: OS:

 

 [2000-12-19 20:55 UTC] vitaliyf at gameaholic dot com
Running ucfirst() on a string which is already all capitalized has no effect:

<?php print ucfirst("HELLO WORLD"); ?>
will print "HELLO WORLD".

The expected behavior here is probably to return "Hello World".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-19 21:07 UTC] vitaliyf at gameaholic dot com
A little correction:

Above bug report refers to ucwords(), however ucfirst() has exact same problem.  ucfirst("HELLO WORLD") should return "Hello world".
 [2000-12-19 22:09 UTC] ronabop@php.net
Changed to a feature request.

The first letters are put into upper case, as per the function name and description.... an alternate function such as "title case" could be interesting, but
ucfirst(strtolower($string));
will also accomplish this.
 [2001-01-10 02:03 UTC] david@php.net
This is completely bogus and would break all existing scripts. The purpose of ucfirst is just to uppercase the first letter and make no other changes.

If you really want that, why not simply do ucfirst(strtolower($var)). Ditto ucwords.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 16:01:31 2024 UTC