php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44010 Function: strstr() and stristr()
Submitted: 2008-02-01 01:52 UTC Modified: 2008-02-01 10:26 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: diemuzi at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.5 OS: Archlinux
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: diemuzi at gmail dot com
New email:
PHP Version: OS:

 

 [2008-02-01 01:52 UTC] diemuzi at gmail dot com
Description:
------------
Using these two functions strstr() and stristr().

The bug occurs only while using "true" when cutting characters from a string to return the value before the cut.

Reproduce code:
---------------
$email  = 'name@example.com';
$domain = strstr($email, '@', true);
echo $domain;

Expected result:
----------------
name

Actual result:
--------------
Warning: Wrong parameter count for strstr()

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-01 08:23 UTC] rabbi at naglfar dot hu
Or it's will be added in the 6.0.0 version...
 [2008-02-01 08:30 UTC] rabbi at naglfar dot hu
Until then use this:
$user = substr ($email, 0, strpos ($email, "@"));
 [2008-02-01 10:26 UTC] felipe@php.net
Documentation says on changelog section:
- 6.0.0   Added the before_needle parameter.

And the new parameter is optional, the doc shows it wrong.
I'll fix it.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Mar 12 04:01:30 2025 UTC