2010-12-31 5 views
10

यहाँ त्रुटि है पीएचपी 5.2+मैं स्ट्रॉप्स() "खाली डेलीमीटर" त्रुटि को कैसे हल करूं?</p> <p>के लिए::

Warning: strpos() [function.strpos]: Empty delimiter in /helper.php on line 445

और यहाँ है कि लाइन पर कोड है:

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); 
      } 
     } 
    } 
+0

कौन सी लाइन लाइन 445 है? –

+0

क्षमा करें - लाइन 445 कोड I सूची (उपरोक्त) की पहली पंक्ति है - यानी अगर ($ src = $ img-> getAttribute ('src') और strpos ($ src, $ fgParams-> get ('base')) === झूठा) { – Jamison

+0

कृपया helper.php फ़ाइल की जांच करें और लाइन नंबर 445 देखें। हमें बताएं कि लाइन नंबर 445 पर वास्तव में क्या है। –

उत्तर

33

यह त्रुटि तब होती है जब strpos को दूसरा पैरामीटर है खाली। उदाहरण के लिए, मैं आसानी से कमांड लाइन पर इस त्रुटि अनुकरण कर सकते हैं:

$ php 
<?php 
echo strpos("foo", ""); 
?> 
^D 
Warning: strpos(): Empty delimiter in - on line 2 

अपने कोड में, इसका मतलब है कि $fgParams->get('base') खाली है।

यह सुनिश्चित करने के लिए कि आपके द्वारा स्ट्रॉस पर जाने वाले मान मान्य हैं, और त्रुटि दूर हो जाएगी, यह सुनिश्चित करने के लिए अपने कोड में कुछ चेक जोड़ें।

1

लाइन 445

बदलें

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 

है कि मिल ('आधार') की तरह लगता है कुछ भी नहीं लौटने है। क्या यह आपकी लिपि में संभव है? शायद यह कार्यक्रम के किसी अन्य क्षेत्र में पिछली त्रुटि का संकेत है।

0

कृपया सुनिश्चित करें कि $ fgParams-> get ('base') का मूल्य खाली नहीं है क्योंकि जेसन ने स्थिति में उल्लेख किया है।

0

मैं के साथ एक ही समस्या थी:

if (htmlentities($controleren[$aantaltekens] == htmlentities($trans[$tellen]) 

त्रुटि गायब हो गया जब मैं दो () सीमांकक कहा:

if (htmlentities($controleren[$aantaltekens]) == htmlentities($trans[$tellen])) 

तो कोशिश:

if(($src = $img->getAttribute('src') AND strpos($src,$fgParams->get('base'))) === false) 

अनुमान htmlentities की आवश्यकता है इसके पैरामीटर (delimiters) के भीतर होना चाहिए।

+1

स्टैक ओवरव्लो में आपका स्वागत है! यदि आप अपना उत्तर थोड़ा सा प्रारूपित करते हैं, तो यह अधिक पठनीय हो जाता है और संभावना है कि लोग इसके लिए मतदान करेंगे। आप पाठ के नीचे _editt_ बटन का उपयोग करके इसे संपादित कर सकते हैं। –

संबंधित मुद्दे