A search engine crawls your website just like a user does. They send a HTTP (usually) request and search the page source that is returned from the server (your delivered content, in this case your PHP's output).
This means search engines never see your server side code like PHP, they see exactly the same as a user. So your two solutions are actually identical.