Bug #52198 [NEW]: strpos not working correctly
| From: | christian dot gnoth at arcor dot de | Date: | Mon, 28 Jun 2010 10:04:41 +0000 |
| Subject: | Bug #52198 [NEW]: strpos not working correctly | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-151920@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux
PHP version: 5.2.13
Package: Strings related
Bug Type: Bug
Bug description:strpos not working correctly
Description:
------------
Hello,
I try to find a string in another string using strpos. If both the string
are passed to the strpos function enclosed in ' it is working properly and
the position is returned. If I put the string - in which the other string
has to be find - in a variable and pass the variable to the strpos function
I get FALSE.
Maybe a problem of character conversion or php configuration????
the website is: joomla-wp.it-gnoth.de
with it-gnoth.de/phpinfo.php your will see the complete configuration.
the string which is to be searched:
href="index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97"
the string which has to be find:
article&id=
below the php source code - both if version get the same result. It goes
always in the else tree.
Test script:
---------------
function j2wp_change_single_url( $j2wp_post, $lnk_pos )
{
global $CON,
$wpdb;
$j2wp_wp_tb_prefix = get_option('j2wp_wp_tb_prefix');
$j2wp_joomla_tb_prefix = get_option('j2wp_joomla_tb_prefix');
$permalink = false;
// $lnk_pos ---> pos at href=" string in post_content
// $post_lnk_end ---> pos at last " in link string of post_content
// $post_lnk_string ---> contains the whole link string inkl. " at the
end
$post_lnk_end = strpos( $j2wp_post['post_content'], '"', $lnk_pos +
7);
$post_lnk_string = substr( $j2wp_post['post_content'], $lnk_pos,
$post_lnk_end - $lnk_pos + 1 );
if ( !(strrpos( $post_lnk_string, '/') === false) )
$pos_lnk_last_slash = strrpos( $post_lnk_string, '/');
// urls with structure:
index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97
// if ( !(strpos( $post_lnk_string, 'article&id=') === false) )
if ( $pos_article_id = strpos( $post_lnk_string, 'article&id=') )
{
$pos_article_id += 11;
$article_id = j2wp_extract_number( substr( $post_lnk_string,
$pos_srticle_id ) );
$url_post_id = j2wp_get_post_url_for_id( $article_id );
$permalink = get_permalink( $url_post_id );
}
else
{
......
--
Edit bug report at http://bugs.php.net/bug.php?id=52198&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52198&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52198&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52198&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52198&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52198&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52198&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52198&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52198&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52198&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52198&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52198&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52198&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52198&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52198&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52198&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52198&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52198&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52198&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52198&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52198&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52198&r=mysqlcfg