Jump to content

I want to include part of a file, not the whole file, using PHP Include


ocetalo

Recommended Posts

e.g. keeping all the <p> I use in my web site stored in a single file, then refer to any of them from the respective page, or doing something like that. I hope I make understood.

Please give easy answer, I'm just learning. Thanks in advance. God bless you.

The only way you could do it, is to set a variable then include like this...

 

$page=about;
include './content.php'

 

Then in your included file do this...

 

switch($page) {

case 'about':
    ?><p>Random paragraph</p><?php
    break;
case 'contact:
    ?><p>Contact Me</p><?php
    break;

}

 

Something like that should work.

 

ILMV

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.