• I have inserted some HTML in a page which references PHP code that I’ve written. Where can I place the PHP code so that the HTML code can access it. I don’t want to have it inline with the HTML code.

Viewing 4 replies - 1 through 4 (of 4 total)
  • php is server-side code…you will need to have your php in a file on the server. If you explain what you are trying to do, then maybe someone can better help…I’m not sure what you mean when you say you want the “html code to access it.”?

    Thread Starter maryandpaul

    (@maryandpaul)

    When I access the web page with the HTML code it references PHP code that I have written. I will place the PHP code in my WordPress application on the server, but I need to know where to place it so that it will be in the path of the HTML code. I don’t want to place it inline with the HTML.

    That’s the wrong way around. HTML can’t reference, call or include a PHP file. A PHP script, on the other hand, can include external HTML files.

    I’d suggest placing both sets of files in your current theme folder.

    I have implemented and seen php scripts inside html code. The web server requires to be instructed to parse the html for PHP scripts, then execute them on the server and then serve the content to the client.

    For apache servers, there are a few ways of doing this, one common way is using these apache’s handlers:

    AddType application/x-httpd-php .php .htm .html
    RemoveHandler .html .htm

    Though for wordpress, I would like also to add php scripts or any server side scripting, to deliver content on post and other wordpress pages so to maximize SEO.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Where To Place PHP Code’ is closed to new replies.