2013-06-01 76 views
0

我有一個使用phorm的舊網站。當提交表單時我得到這個錯誤:strlen()期望參數1是字符串,數組給定

警告:strlen的()預計參數1是字符串數組中/home/user/public_html/form/phorm.php給出線2015年

我知道這是因爲升級到PHP 5.3,是否有一種簡單的方法來修復該代碼行以使我的表單再次工作?

if (strlen($PHORM_ALERTTO) && !strlen($PHORM_TO) && !$PHORM_INFONLY && !$ph_GotData) { 
    $PHORM_TO = $PHORM_ALERTTO; //THIS IS LINE 2015 





Read the mail template file(s) and mail it (them) to the user */ 
    $ph_section = "user template"; 
    if (strlen($PHORM_ALERTTO) && !strlen($PHORM_TO) && !$PHORM_INFONLY && !$ph_GotData) { 
    $PHORM_TO = $PHORM_ALERTTO; //THIS IS LINE 2015 
    settype($PHORM_TO, "array"); 
    } 
    if (isset($PHORM_TMPL) && isset($PHORM_TO) && !$ph_Abort) { 
    if ($ph_debug2) echo "<B>JS:</B> Mail Template(s)<BR>"; 

    if (count($PHORM_TMPL) > $ph_MaxTMPL) $ph_Alerts['120'] = ph_Message("A120"); 

    list(,$fPHORM_TO)  = each($PHORM_TO); 
    list(,$fPHORM_SUBJECT) = each($PHORM_SUBJECT); 

    while ($ph_MaxTMPL-- && list($ph_key, $lPHORM_TMPL) = each($PHORM_TMPL)) { 
     if ($lPHORM_TMPL == ph_GENERIC) $lPHORM_TMPL = "$ph_root/files/generic.txt"; 
     else       $lPHORM_TMPL = "$ph_tpd/$lPHORM_TMPL"; 

     $ph_Message = ""; 
     $ph_Headers = ""; 
     $ph_NonHeader = ""; 

     $lPHORM_TO  = ""; 
     $lPHORM_FROM = ""; 
     $lPHORM_SUBJECT = ""; 
     $lPHORM_HEADERS = ""; 

     $ph_TemplateHeaders = false; 
     if (ereg("(.+) +\+h$", $lPHORM_TMPL, $ph_regs)) { 
     $lPHORM_TMPL = trim($ph_regs[1]); 
     $ph_TemplateHeaders = true; 
     } 

     if ($ph_debug8) echo "Mail Template <B>$lPHORM_TMPL</B><BR>"; 

     if (!$ph_Template = @implode("", file($lPHORM_TMPL))) { 
     $ph_Alerts['005'] = ph_Message("A005"); 
     if ($php_errormsg) $ph_Alerts['005P'] = "%%%: $php_errormsg"; 
     continue; 
     } 
+0

這是因爲,你只能用它來計算字符串,如果你想計算一個數組使用'count()' – samayo

+0

所有在警告中說... – user544262772

+0

任何意見,我需要改變那一行的代碼? –

回答

3

這是因爲你正在使用strlen()算一個數組,而它應該當你需要計算的字符串使用。你的錯誤很明顯。

如果您需要對一個數組進行計數或更多,只需使用countsizeof函數。

+0

@PeterEastwood錯誤意味着你對一個數組使用了一個函數'strlen',所以$ PHORM_ALERTTO和/或$ PHORM_TO都是數組,試着改成'if(count($ PHORM_ALERTTO)&&!count ($ PHORM_TO)&&!$ PHORM_INFONLY &&!$ ph_GotData){$ PHORM_TO = $ PHORM_ALERTTO;' – Fabio

+0

非常感謝@Fabio的作品 –

+0

@PeterEastwood不客氣! – Fabio

相關問題