Jump to content

[SOLVED] strpos "Empty delimiter"


jp2php

Recommended Posts

I've got a short script that parses a directory. While parsing this directory, I look to see if this is the file I want, using this code snippet:

Line 89: $strpos = strpos($file1, $file2, 0);
Line 90: if (($strpos !== false) && ($strpos == 0)) {
Line 91:   echo("Found it!");
Line 92: }

 

The code works, but it posts this warning for every file it encounters during the search:

Warning: strpos() [function.strpos]: Empty delimiter in /localhost/test.php on line 89

 

I know I could simply suppress the warning by using @strpos, but why am I getting this warning?

 

(I did a search online for this first, but it pulled up many, many irrelevant results.

Link to comment
https://forums.phpfreaks.com/topic/164769-solved-strpos-empty-delimiter/
Share on other sites

Could you post line 89 for us?

 

It's up there in the original post.

 

I found the problem, though. I failed to declare my file being searched for using *global* before passing it to my function.

 

Stupid, newby mistake. Everyone says how similar PHP and C are, then PHP throws me a curve like that!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.