php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24228 ternary condition
Submitted: 2003-06-17 13:33 UTC Modified: 2003-06-17 13:34 UTC
From: alexdg at joimail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.1 OS: windows xp
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: alexdg at joimail dot com
New email:
PHP Version: OS:

 

 [2003-06-17 13:33 UTC] alexdg at joimail dot com
Description:
------------
maybe i'm dumm, but i can't understand why the following code doesn't work properly.
strlen($s_fnc_note) is > 45, but it echoes ' ' instead.


Reproduce code:
---------------
$s_fnc_note 	= 'asf asf asfda sdf asdfa sf asdf asdf asdf asdf asdf asdf asdfasdf asdf asdfasdf asdfasdf asdfas asdfasdfasdf asdfasdf';
echo (strlen($s_fnc_note) > 45)?substr($s_fnc_note,0,42).'...':(strlen($s_fnc_note) == 0)?' ':$s_fnc_note;

Expected result:
----------------
i do expect to echo substr($s_fnc_note,0,42).'...'


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-17 13:34 UTC] derick@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. 

Thank you for your interest in PHP.

try to add some ( and )\'s
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 13:01:33 2025 UTC