更正 WordPress 插件中的非法字符串偏移警告 [英] Correcting a Illegal String Offset warning in WordPress Plugin

查看:26
本文介绍了更正 WordPress 插件中的非法字符串偏移警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误警告:第 250 行的 contact-me.php 中的非法字符串偏移量 'width'

I am receiving this error "Warning: Illegal string offset 'width' in contact-me.php on line 250

警告:contact-me.php 中第 252 行的非法字符串偏移量title""

Warning: Illegal string offset 'title' in contact-me.php on line 252"

然后我意识到文件中的这部分代码是错误的,但是我还不太擅长 PHP,我想知道是否有人可以帮助我重新编写这部分代码以消除错误.谢谢!(错误开始于以 $width 开头的第 250 行和以 $title 开头的第 252 行).

and I realized this section of code in the file is wrong, however I'm not quite adept in PHP yet and I am wondering if someone can help me re-write this section to eliminate the error. Thanks! (the error starts on line 250 which begins with $width below and also line 252 which begins with $title).

我尝试在其他线程上实施一些更正,但没有成功.感谢您的帮助.

I tried implementing some of the corrections on other threads but was unsuccessful. I appreciate your assistance.

function shortcode_handler($_atts) {
    if ($this->check_settings() === true) {
        $width = intval($_atts["width"]);
        if ($width < 100 || $width > 1000) $width = "";
        $title = $_atts["title"];
        if (empty($title)) $title = htmlspecialchars($this->options['form_title'], ENT_QUOTES);
        $suffix = "_".rand(1000, 9999);
        $form = '

我解决了.我使用了以下代码:

I solved it. I used the following code:

if (isset($_atts["width"]))
        $width = var_dump($_atts["width"]);           
  if (isset($_atts["title"])) 
        $title = var_dump($_atts["title"]);

推荐答案

我使用了以下代码:

if (isset($_atts["width"]))
    $width = var_dump($_atts["width"]);           
if (isset($_atts["title"])) 
    $title = var_dump($_atts["title"]);

这篇关于更正 WordPress 插件中的非法字符串偏移警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆