dsdqpdjpq16640651 2017-05-14 13:47
浏览 38

PHP如果加载图像,则根据哪个图像回显文本

Im pretty new to programming and Im currently doing it as a school project. I hope Im asking the right question here.

Im trying to get my page to echo a specific sentence, depending on which image is loaded. Say IMAGE1.jpg is loaded, I want my page to echo "TEXT A", but if IMAGE2.jpg is loaded, I want my page to echo "TEXT B" instead.

How do I do this?

  • 写回答

1条回答 默认 最新

  • doufu2396 2017-05-14 16:24
    关注

    Not sure how you mean "loaded", if you mean in the page, then it's probably best to use JavaScript. PHP is server side and processed before the DOM (the html part) is even loaded.

    In Javascript you'd need to get all the images with a certain class that you want to check, or you could check id's to see which is on the page, if all are on the page you could check their css to see if the "display" property is set, and if it is you then know which one is loaded and shown.

    I wont spoonfeed you the code because it's good to learn, and when you get it working you will feel very proud.

    I suggest learning a little bit of jQuery, a little bit of JavaScript, and some HTML. PHP is mainly used for lots of data stuff like storing and meddling with values, whereas JS is more a make stuff move and see what's there kinda language (:

    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊