strtolower将会话传递给变量,这是合法的吗?

Is it alright to do this?

$author = strtolower($_SESSION['valid_username']);

I want to enter all authors into the table as lower case.

Yes, that's fine as long as $_SESSION['valid_username'] is set, otherwise you'll get a notice (if your error reporting is set that low).

You can check if it exists with if (isset($_SESSION['valid_username']))

yes.

$_SESSION['valid_username']

is a session variable which evaluates to a string so passing it as a parameter to the strtolower function is not a problem.