php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3969 Strpos won't return the 1st instance of string
Submitted: 2000-03-29 18:24 UTC Modified: 2000-03-30 09:44 UTC
From: iliaa at home dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Release Candidate 1 OS: Linux 2.2.14
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: iliaa at home dot com
New email:
PHP Version: OS:

 

 [2000-03-29 18:24 UTC] iliaa at home dot com
// Sample Code

$position = strpos("http://www.php.net", ".");
echo substr("http://www.php.net", 0, $position);

// Result

http://www.php

The problem is that according to the docs strpos is supposed to return the position of the 1st occurance of the character in the string (strpos -- Find position of first occurrence of a string).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-30 09:44 UTC] andrei at cvs dot php dot net
There is no problem here. $position contains the position of the first
occurrence of "." and then you get the exact result that you need.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Apr 15 02:00:01 2026 UTC