PHP adding include to a generated web page

7 replies
Any ideas on how to add an include code to generated web pages. I'd like to keep some text and features up to date on each generated page.

Say I generate a get file contents line in the generated web page then I can echo the new text on web pages previously generated as well.

Rick
#adding #generated #include #page #php #web
Avatar of Unregistered
  • Profile picture of the author priyag chaudhary
    I hope it's works
    you can also place your JavaScript code into a separate file (with a . js extension), and call that file in your HTML document through the src attribute of the <script> tag.
    {{ DiscussionBoard.errors[11581900].message }}
  • Hi Rick,
    by just calling "echo file_get_contents("mygen_page.php");" should work. Whatever you have in mygen_page.php as a PHP code will be generated into HTML and then output to the parent caller (the echo you have).
    {{ DiscussionBoard.errors[11582427].message }}
  • Profile picture of the author Ragni Vallejo
    Hi Rick, sorry for this late reply I'm a new user but I would like to share a thought.

    I normally use php includes for the header, menus and footer of my web designs as to only make changes in those relevant files that get included throughout the poroject. I've save many countless hours when having to update these sections.

    I do it like this:

    include("header.php");

    as an example
    {{ DiscussionBoard.errors[11584595].message }}
    • Profile picture of the author hometutor
      Originally Posted by Ragni Vallejo View Post

      Hi Rick, sorry for this late reply I'm a new user but I would like to share a thought.

      I normally use php includes for the header, menus and footer of my web designs as to only make changes in those relevant files that get included throughout the poroject. I've save many countless hours when having to update these sections.

      I do it like this:

      include("header.php");

      as an example
      I do the same. What I was looking for and I'll give echo a try, is a way to add to include command itself to an autogenerated page so it could have the same flexibility as my hand made pages which have the include command.

      Rick
      {{ DiscussionBoard.errors[11585356].message }}
  • Profile picture of the author shapovalov085
    You did't provide your code example. I can suggest you have something like:
    Code:
    $output = 'Lorem ipsum ... dynamic content';
    echo $output;
    To add included file contents like mycontent.php to $output as string use this:
    Code:
    $output = 'Lorem ipsum ... dynamic content';
    ob_start();
    include('mycontent.php');
    $output .= ob_get_contents();
    ob_end_clean();
    echo $output;
    {{ DiscussionBoard.errors[11584875].message }}
    • Profile picture of the author hometutor
      Originally Posted by shapovalov085 View Post

      You did't provide your code example. I can suggest you have something like:
      Code:
       = 'Lorem ipsum ... dynamic content';
      echo ;
      To add included file contents like mycontent.php to as string use this:
      Code:
       = 'Lorem ipsum ... dynamic content';
      ob_start();
      include('mycontent.php');
       .= ob_get_contents();
      ob_end_clean();
      echo ;
      I appreciate your time, but that adds the file not the include command itself.

      Rick
      {{ DiscussionBoard.errors[11585355].message }}
Avatar of Unregistered

Trending Topics