You can't run php in the WordPress editor. You can enable php execution in the editor, though it's not a good idea if other users will be editing. You can execute php, of course, in template and theme files.
And you can execute php in a widget if you use the WordPress › PHP Code Widget plugin.
But relative paths will work in the html editors and continue to work in most cases. See Relative URLs in Wordpress
But you can allow the test server or localhost domains to be inserted by the editor by WordPress, and then use interconnectit.com WordPress Serialized PHP Search Replace Tool to migrate the URLs. That tool correctly serializes/reserializes data in the database, so there is no breakage.