PHP:如何测试数据库链接是否仍然有效?

When one retrieves a database $link with mysql_connect(), how can one check if that link is still valid after some time? (I am not asking whether the returned is valid, I mean later)

You can use mysql_ping() or mysqli_ping() for this. However, in a regular web application you should just execute your queries and abort with an error if a query failed (or retry once).

There's no reason to test.

Just execute the query, and you will see...