问题描述:

This question already has an answer here:

  • Reference: What is variable scope, which variables are accessible from where and what are “undefined variable” errors?

    3 answers

网友答案:

I think you are confusing the concept of a server side language. Your php code and html code are generated on the server and sent to the client, which is your computer. Now when you look at the images of those teachers php code has already been executed and cannot be executed on the client side. You should learn Javascript, which can be used for client side tasks. To cut it short, you php code is already done running when you are presented with the html page in front of you. The solution may be is to add event listeners to your images and fire events based on the id of the image. Seems like you are new to this so take a look at Jquery.

相关阅读:
Top