Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中如何在锚定标记中插入alt标记?_Php_Html - Fatal编程技术网

在php中如何在锚定标记中插入alt标记?

在php中如何在锚定标记中插入alt标记?,php,html,Php,Html,我想为logo.png添加一个ALT标记 谢谢如果您使用的是CodeIgniter框架,您可以这样做 来自Codeigniter文档 <div > <a href="<?=site_url()?>"><?=img('logo.png',array('class'=>'logo'))?></a> </div> 如果您使用的是CodeIgniter框架,您可以这样做 来自Codeignit

我想为logo.png添加一个ALT标记


谢谢

如果您使用的是CodeIgniter框架,您可以这样做

来自Codeigniter文档

    <div >
        <a href="<?=site_url()?>"><?=img('logo.png',array('class'=>'logo'))?></a>
    </div>

如果您使用的是CodeIgniter框架,您可以这样做

来自Codeigniter文档

    <div >
        <a href="<?=site_url()?>"><?=img('logo.png',array('class'=>'logo'))?></a>
    </div>

我猜您正在使用某种框架,因此答案可能不正确。 请试试这个:

$image_properties = array(
          'src' => 'images/picture.jpg',
          'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time',
          'class' => 'post_images',
          'width' => '200',
          'height' => '200',
          'title' => 'That was quite a night',
          'rel' => 'lightbox',
);

img($image_properties);

我猜您正在使用某种框架,因此答案可能不正确。 请试试这个:

$image_properties = array(
          'src' => 'images/picture.jpg',
          'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time',
          'class' => 'post_images',
          'width' => '200',
          'height' => '200',
          'title' => 'That was quite a night',
          'rel' => 'lightbox',
);

img($image_properties);


您不能在锚定标记中使用alt属性,而是使用title属性,或者,如果它是一个图像(如您的情况),则它是一个徽标。您可以使用img标记和alt属性

可能是稍微修改一下

  <div >
        <a title="your site" href="<?=site_url()?>"><?=img('logo.png',array('class'=>'logo'))?></a>
    </div>


您不能在锚定标记中使用alt属性,而是使用title属性,或者,如果它是一个图像(如您的情况),则它是一个徽标。您可以使用img标记和alt属性

可能是稍微修改一下

  <div >
        <a title="your site" href="<?=site_url()?>"><?=img('logo.png',array('class'=>'logo'))?></a>
    </div>

查看代码后,您可能会使用“codeigniter”框架,下面是代码的解决方案。下面的代码显示了如何在img函数中添加属性。您只需传递一个数组,该数组包含属性和值

<a href="<?=site_url()?>"><img src="<?=img('logo.png',array('class'=>'logo'))?>" alt="your site" /></a>


请更正您的语法

查看代码后,您可能会使用“codeigniter”框架,下面是代码的解决方案。下面的代码显示了如何在img函数中添加属性。您只需传递一个数组,该数组包含属性和值

<a href="<?=site_url()?>"><img src="<?=img('logo.png',array('class'=>'logo'))?>" alt="your site" /></a>


请更正您的语法

您使用的是哪种PHP框架?代码点火器?你是指img元素的alt属性吗?alt在哪里?这难道不是一个格式错误的链接吗?@KanishkaPanamaldeniya是的,codeigniter你在使用哪个PHP框架?代码点火器?你是指img元素的alt属性吗?alt在哪里?这难道不是一个格式错误的链接吗?@KanishkaPanamaldeniya是的,codeigniteranchor标记没有alt属性。它不在锚标记内,它在一些img()php函数内,该函数应该打印一个img标记。锚标记没有alt属性。它不在锚标记内,它在一些img()php函数内,它应该打印一个img标签。。