Mathias Asberg
Mathias Asberg

Reputation: 3840

How can i import html with php?

This is a really simple one but it's driving me crazy.

I want to import regular HTML code with the help of PHP.

<?php get_thefile ?>

Is that correct? And what shall the thefile.php contain to get it right except my HTML content that I want to import of course!

More information

In a category part of a website i want to put a sidebar that will show some information, this can be anything from html to flash. This content will change time to time so insteed of editing 100 pages i want to just edit this file, My php skill is 0,1% and i can't relly find what i shall exactly do, So what i need is

1: The code to place in the page

2: What i shall put in the file before ? and after ? my content that i want to import

The file will be in the same folder on server as the main page, the page is php and it's wordpress

Upvotes: 6

Views: 26765

Answers (5)

Uladzimir Pasvistselik
Uladzimir Pasvistselik

Reputation: 3921

<?php include 'thefile.php'; ?>

include Documentation

Upvotes: 1

Robert Van Sant
Robert Van Sant

Reputation: 1507

I'm not sure what you're trying to accomplish, but if it's external HTML, you could use

<?php echo file_get_contents('http://EXTERNAL_URL'); ?>

again, not fully sure what you're trying to do. i hope this helps.

Upvotes: 8

Karoly Horvath
Karoly Horvath

Reputation: 96266

If you just want to directly output the file, use readfile.

Upvotes: 3

switz
switz

Reputation: 25188

Use $html = file_get_contents('link_to_html.html');

Upvotes: 2

lc2817
lc2817

Reputation: 3742

You certainly want to use include as described here.

Upvotes: 2

Related Questions