问题
I am receiving this error "Warning: Illegal string offset 'width' in contact-me.php on line 250
Warning: Illegal string offset 'title' in contact-me.php on line 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"]);
回答1:
I used the following code:
if (isset($_atts["width"]))
$width = var_dump($_atts["width"]);
if (isset($_atts["title"]))
$title = var_dump($_atts["title"]);
来源:https://stackoverflow.com/questions/21318585/correcting-a-illegal-string-offset-warning-in-wordpress-plugin