PHP — What does Warning: strpos() [function.strpos]: Empty delimiter in mean?
What does Warning: strpos() [function.strpos]: Empty delimiter in mean?
Answers
At a guess, I’d say $text is an empty string (thanks Mark for pointing out the specifics)
Edit: Also, another guess is you have the parameters in the wrong order. The method signature of strpos is
int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
Here’s what worked best for me when trying to script this (in case anyone else comes across this like I did):
$ pecl -d php_suffix=5.6 install $ pecl uninstall -r $ pecl -d php_suffix=7.0 install $ pecl uninstall -r $ pecl -d php_suffix=7.1 install $ pecl uninstall -r
The -d php_suffix= piece allows you to set config values at run time vs pre-setting them with pecl config-set . The uninstall -r bit does not actually uninstall it (from the docs):
[email protected]:~$ pecl help uninstall pecl uninstall [options] [channel/] . Uninstalls one or more PEAR packages. More than one package may be specified at once. Prefix with channel name to uninstall from a channel not in your default channel (pecl.php.net) Options: . -r, --register-only do not remove files, only register the packages as not installed .
The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).
How do I resolve a strpos() «empty delimiter» error?
This error occurs when the second parameter to strpos is empty. For instance, I can easily simulate this error at the command line:
$ php ^D Warning: strpos(): Empty delimiter in - on line 2
In your code, it means that $fgParams->get(‘base’) is empty.
Add some checks to your code to ensure that the values you pass to strpos are valid, and the error will go away.
Solution 2
if($src = $img->getAttribute('src') AND strpos($src,$fgParams->get('base')) === false) < // prevents repeat processing
if($src = $img->getAttribute('src') AND $fgParams->get('base')!="" AND strpos($src,$fgParams->get('base')) === false) < // prevents repeat processing
Seems like that get('base') is returning nothing. Is this possible in your script? perhaps it's the indication of a previous error in another area of the program.
Related videos on Youtube
Jamison
Hacking my way through Egiva.com - come check it out!
Comments
if($src = $img->getAttribute('src') AND strpos($src,$fgParams->get('base')) === false) < // prevents repeat processing EgivaUtility::profiling('Processing Image SRC: '.$src); // fix rel paths $src = EgivaUtility::encode_url(EgivaUtility::makeAbsUrl($origLink,$src)); if($image_details = @getimagesize($src) AND !in_array($image_details[0],array(1,2)) AND !in_array($image_details[1],array(1,2))) < EgivaUtility::profiling('Image Details: '.print_r($image_details,true)); $title = $img->getAttribute('title'); $alt = $img->getAttribute('alt'); if($fgParams->get('save_img')) < // consider restoring the JPath::clean() // find image name and extension $name = $title ? EgivaUtility::stringURLSafe($title) : EgivaUtility::stringURLSafe($alt); preg_match('#[/?&]([^/?&]*)(\.jpg|\.jpeg|\.gif|\.png)#i',$src,$matches); $ext = isset($matches[2]) ? strtolower($matches[2]) : ''; if(!$name) $name = isset($matches[1]) ? EgivaUtility::stringURLSafe($matches[1]) : md5($src); unset($matches); //create image file $filename = $fgParams->get('name_prefix').$name.$ext; $filepath = $fgParams->get('savepath').'images'.DS.$filename; if(!file_exists($filepath)) < if($contents = EgivaUtility::getUrl($src,$fgParams->get('scrape_type'),'images',$filepath)) < $saved = true; //if(EgivaUtility::savefile($contents,$name,$update=false,$header=null,$fgParams->get('savepath').'images')) $saved = true; > > else < $saved = true; >if($saved) $img->setAttribute('src', $fgParams->get('srcpath').'images/'.$filename); > else < $img->setAttribute('src',$src); > EgivaUtility::profiling('Final Image SRC: '.$img->getAttribute('src')); // $class = $img->getAttribute('class'); // $width = $img->getAttribute('width'); // $height = $img->getAttribute('height'); if(strlen($alt) >= JString::strlen($content['title']) OR !$alt) < $img->setAttribute('alt',$content['title']); > if($fgParams->get('rmv_img_style')) < $img->removeAttribute('class'); $img->removeAttribute('style'); $img->removeAttribute('align'); $img->removeAttribute('border'); $img->removeAttribute('width'); $img->removeAttribute('height'); > if($fgParams->get('img_class')) < $img->setAttribute('class',$fgParams->get('img_class')); > $new_img = $dom2->importNode($imgs->item($k),true); $dom2->appendChild($new_img); $images[$k] = $dom2->saveHTML(); $dom2->removeChild($new_img); // hack to avoid encoding problems $text = preg_replace($regex,'fg_img'.$k,$text,$limit=1); $replace[$k] = 'fg_img'.$k; $k++; > else < EgivaUtility::profiling('Image Rejected'); $text = preg_replace($regex,'',$text,1); >> >
Welcome to StackOverflow! If you format your answer a little, it becomes more readable and chances are higher people will vote for it. You can edit it using the editt Button below the text.
How do I resolve a strpos() "empty delimiter" error?
This error occurs when the second parameter to strpos is empty. For instance, I can easily simulate this error at the command line:
$ php ^D Warning: strpos(): Empty delimiter in - on line 2
In your code, it means that $fgParams->get('base') is empty.
Add some checks to your code to ensure that the values you pass to strpos are valid, and the error will go away.
Read More
Please make sure that value of $fgParams->get('base') is not blank as json mentioned in condition.
I had the same problem with:
if (htmlentities($controleren[$aantaltekens] == htmlentities($trans[$tellen])
The error disappeared when I added the two () delimiters:
if (htmlentities($controleren[$aantaltekens]) == htmlentities($trans[$tellen]))
if(($src = $img->getAttribute('src') AND strpos($src,$fgParams->get('base'))) === false)
Guess htmlentities requires its parameters to be within (delimiters).
if($src = $img->getAttribute('src') AND strpos($src,$fgParams->get('base')) === false) < // prevents repeat processing
if($src = $img->getAttribute('src') AND $fgParams->get('base')!="" AND strpos($src,$fgParams->get('base')) === false) < // prevents repeat processing
Seems like that get('base') is returning nothing. Is this possible in your script? perhaps it's the indication of a previous error in another area of the program.
More Answer
- How do I resolve the error "PHP Notice: Use of undefined constant"?
- how to resolve Unknown SSL protocol error in connection to connect20.magentocommerce.com:443
- how to resolve this error on wamp?
- How to resolve Call to undefined function idn_to_ascii() error in php 7.3.8?
- What does net::ERR_INCOMPLETE_CHUNKED_ENCODING mean and how may I resolve it?
- Need to exit a function if var is empty and make ajax display an error PHP/AJAX
- How to test for empty recordset
- How to catch this low level MySQL (?) error in PHP/Magento
- How do you resolve Duplicate title/meta tags on pages with pagination? What are the Best practices?
- How to configure PHP to display detailed errors instead of error 500 page?
- How to configure PHPUnit to regard dataprovider error as failure and not warning?
- How come I'm not getting an error in PHP when records aren't inserting (prepared statement)?
- "Couldn't find object" error with Silverstripe 4 unit testing, how to fixed it?
- Resolve Laravel Passport 2.0 installation Error
- How to get error message from pg_insert()?
- How do I fix '530-5.5.1 Authentication Required' error when trying to send e-mail from localhost?
- How to Handle Parse error using register_shutdown_function() in php?
- mail() function not working - How to resolve it?
- Mongo / PHP wrapper error - how do i get the wrapper working?
- yii how to show the custom error msg with validation failed msg
- How to get strpos in PHP to match foreign language characters?
- MIT APPInventor error on openning. How to fix it?
- How to ignore undefined variable error in PHP
- How to display error messages in red font color on form using jQuery?
- How to check the input value is not empty spaces?
- How to remove skip empty line when I read a file
- How to enable error reporting in nginx php config
- How do I configure a 404 error page in MODX?
- how can i solve " Deprecated: Function eregi() is deprecated" error
- how to check if a URL exists or not - error 404 ? (using php)
- How not to send empty input value in GET-query
- How to check if an array is empty in PHP(Codeigniter)
- How to catch the error of file_get_contents() in php
- How to identify the query that caused the error using mysqli_multi_query?
- How do i change a symfony form error message?
- Error on strings that contains "&" in XML. How can I fix this?
- how we could create translate validate error messages on zend framework?
- How to hightlighting php syntax error by Sublime Text 3?
- php array empty - how to get NOT
- Why is session data empty in Symfony2 and how to access it?
- php error log, how to remove the duplicates/find unique errors
- how to stop form submit if empty fields?
- Trying to delete an entry in a database, recieve an sql error but can't work out how
- How to prevent having the "is not a valid image file" error when using GD function imagecreatefrom* in php?
- How to explode array by multiple delimiter characters
- How to send an error response from php to a jQuery Ajax post request
More answer with same ag
- How to use in_array and isset in twig template?
- php code turned gibberish?
- Nest Rest API Connection Refused
- What is the easiest way to log how long someone is viewing a page using PHP?
- Switching from PHP to Rails Need Help translating URL shortener
- Prevent screen output heredoc
- Set up cookie for page visit
- Matching substrings with placeholders
- php zlib gzopen not exists
- finding a hosting company with unixODBC and FreeTDS support
- Regex expression for mail address
- Sum of all the numbers in a column for 3 tables?
- Format date within an echo
- Angular - send HTTP post data to server [HOW TO]
- How do I take values from two different HTML textboxes?
- Laravel: Solution for multiple jobs using HttpClient?
- Doctrine with legacy database, get fields from multiple tables
- Register annotation router
- How to create retina image from JPEG with PHP
- Sendgrid - Receiver can't receive the email sent using php
- Why doesn't my email regex for PHP work?
- How to pass variables through model binding in laravel?
- Pass large amout of data between PHP and Perl
- WordPress dynamic Options Page from arrays and actually save?
- How to update the price of a hosted paypal button using Button Manager API?
- Is there any way to read character type in PHP?
- php dynamic URL rewrite with a form submit to clean URL
- Separate string using array
- PHP Browser Detection and Redirection
- Text-centred shape in PDF
- How to dynamically handle UNIX/Windows directory separators in yaml files
- How do I use an API?
- Upload image after JavaScript changes
- Processing php code after readfile() - can an iframe work?
- Send XML data to WSDL
- Unique validation on edit a form, in codeigniter
- Pass an attribute of selected option of dropdown list as an arg to a function in 'onchange'
- Heroku style GIT deployment for my own server
- Sum corresponding elements between two multidimensional arrays
- Circular resource dependency error in Zend
- Does anyone knows a web application security scanner for mac?
- Help with consuming JSON feed with PHP & json_decode
- Reading from external html source custom objects
- CakePHP: How is redirect managed if there are more than one steps?
- Namespacing with Composer Pusher Library
- select multi image from gallery for send to server with react-native
- Javascript jQuery Ajax autocomplete over multiple lines
- PHPMailer : Everything works fine for 4 months, but suddenly SMTP connect() failed
- PHP Upload File
- Error with if and foreach