5 Replies - 318 Views - Last Post: 06 February 2012 - 12:25 PM Rate Topic: -----

Topic Sponsor:

#1 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

expand and collapse included PHP content?

Posted 06 February 2012 - 09:43 AM

Is there a way to expand and collapse included PHP content?

Any code examples pls.
Is This A Good Question/Topic? 0
  • +

Replies To: expand and collapse included PHP content?

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1942
  • View blog
  • Posts: 7,296
  • Joined: 08-August 08

Re: expand and collapse included PHP content?

Posted 06 February 2012 - 10:08 AM

What does that mean? Code is either executed or not.
Was This Post Helpful? 0
  • +
  • -

#3 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

Re: expand and collapse included PHP content?

Posted 06 February 2012 - 11:34 AM

Code is either executed or not???

if i get you right,when i place the
<?php include 'inc/xxxx.php';?>
in the
<div>
it does not hide , it just show it no matter what.

This post has been edited by decongh: 06 February 2012 - 11:36 AM

Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1942
  • View blog
  • Posts: 7,296
  • Joined: 08-August 08

Re: expand and collapse included PHP content?

Posted 06 February 2012 - 11:47 AM

Oh, I see. You think that PHP and HTML are processed in the same place and at the same time. They're not. You cannot place PHP code inside a div. Ever. PHP code is executed on the server before HTML is processed by the browser, which is on a different machine.
Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1942
  • View blog
  • Posts: 7,296
  • Joined: 08-August 08

Re: expand and collapse included PHP content?

Posted 06 February 2012 - 11:53 AM

Just to be clear, look at this:
<div>
<?php
echo "Hello world!";
?>
</div>

What's happening here is that the interpreter sees a bunch of text before the <?php tag and it passes that along to the browser, otherwise completely ignoring it. Then it processes the PHP, which in this case sends the text "Hello world!" to the browser. Next, it sees the end of PHP tag "?>" so everything after that gets ignored and sent on to the browser. The end result is that the browser sees:
<div>
Hello world!
</div>

Note that there is no PHP there!
Was This Post Helpful? 1
  • +
  • -

#6 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 380
  • View blog
  • Posts: 961
  • Joined: 08-March 09

Re: expand and collapse included PHP content?

Posted 06 February 2012 - 12:25 PM

I believe what you are talking about is expanding and collapsing content. This is something that is typically done with Javascript. Where the HTML comes from is irrelevant.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1