百分号在PHP中有什么作用?

Other than as a modulus operator, what does the percent sign do in PHP?

For instance, I am looking at some PHP code, and see the following:

define('TABLE_PREFIX','%CONFIG-PREFIX');

Elsewhere, in a SQL file, I see the following. I expect the SQL script is being parsed by PHP.

DROP TABLE IF EXISTS `%TABLE_PREFIX%api_key`;

Thank you

PHP doesn't intrinsically treat it specially within strings. It must be the application that's parsing the strings and deciding that % indicates some kind of variable value.

In fact, it looks like you're looking at the source code of a project called osTicket. In its installer, I found this line which corresponds to your given define:

$configfile= str_replace('%CONFIG-PREFIX',$_POST['prefix'],$configfile);

In PHP, nothing. Somewhere in whatever database driver you're using, the driver is parsing that string to put the prefix in, most likely with something similar to:

$sql = str_replace( '%TABLE_PREFIX%', TABLE_PREFIX, $sql);