dongyo1818 2012-05-16 18:54
浏览 47
已采纳

变量值是两个字符串

Somehow a variable that SHOULD contain only one string (not an array or anything) contain an url, managed to contain two different values;

string(8) "value 1 " string(7) "value 2"

i cannot use this variable because echoing it or using it in another function would print

value 1 value2

which is not what i need, i need only value 1 and i cannot use $var[0]

Two things; how can i do something similar (one variable two strings), and how can i manipulate it. EDIT : here is the code

public function get_first_image($post) {
        $image_id=get_post_thumbnail_id($post->id);
        $image_url = wp_get_attachment_image_src($image_id,’large’);
        $image_url=$image_url[0];
        var_dump($image_url);
        return $image_url;
    }

the var_dump() results are as mentioned above

Best Regards

  • 写回答

2条回答 默认 最新

  • dongzhi1904 2012-05-16 19:05
    关注

    Don't reuse $image_url as a variable, this is most likely causing your problem. You should rename one of your variables:

    public function get_first_image($post) {
        $image_id = get_post_thumbnail_id($post->id);
    
        $image_array = wp_get_attachment_image_src($image_id,’large’);
        $image_url = $image_array[0];
    
        var_dump($image_url);
        return $image_url;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?