简体   繁体   中英

php include only part of an external page not all of it

using php's include is possible to include part of another page without including all that entire content of that page?

From pageX.php i want Div #A not div #B the whole pageX.php

<div id="A">
<p>Don't show me</p>
</div>
<div id="B">
<p>Display Me</p>
</div>

i'm aware of JQuery's ajax Load but im wondering if there's a method like that in php.

I am not aware of any function that can include a specific part of a php file but typically this can be achieved in two ways.

  1. Split your UI component markups into separate files so that can be included separately and easily re-used in many places. (example here )
  2. Have all the UI components markups as different functions in a common file which can be called easily.

     function printDivA() { echo <<< DIV_A <div id="A"> <p>Don't show me</p> </div> DIV_A; } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM