# @include & disappearing PHP code?

**URL:** <https://forums.realmacsoftware.com/t/include-disappearing-php-code/46839>\
**Category:** Elements API\
**Created:** [March 23, 2025, 3:34pm UTC](https://forums.realmacsoftware.com/t/include-disappearing-php-code/46839 "2025-03-23T15:34:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [March 23, 2025, 3:34pm UTC](https://forums.realmacsoftware.com/t/include-disappearing-php-code/46839/1 "2025-03-23T15:34:19Z")

</div>

I am trying to use the @include function in my DevPack index.php file. 🤔

In the documentation, it says **@include(“hello”)** which looks in the include folder for **hello.html**. I was trying to include **layouts.php** and for that file to include several svg files e.g. **svg\_1.html** via **@include(“svg\_1”)**.

Anyway, didn’t work but more concerning was that none of the PHP code (via a pagestart portal) was output on Preview or Publishing, just the HTML. It took me a while to realise that the issue was triggered by use of **@include**. I had to remove the include folder in the DevPack and quit elements and restart it for the php code to reappear.

So the questions are:

1. Is including PHP code supported?
2. Is nesting includes supported?

Of course the above might be related to the transcribing / corruption of the output PHP code issue? 🤔

---

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [March 23, 2025, 6:56pm UTC](https://forums.realmacsoftware.com/t/include-disappearing-php-code/46839/2 "2025-03-23T18:56:17Z")

</div>

OK, here’s a bit more detail on the issue. 🙂

It seems that just having the **include** folder include in the **templates** folder with only html files in it (no PHP files) and no @include statement in index.php causes the PHP code (in the startpage portal) not to be output by Elements to either Preview or Published.

To recover, I have to delete the include folder in the DevPack and then close Elements down, then restart it and open the Elements project, then force an update on the DevPack by just saving index.php (so the Component icon) flashes in Elements and then re-publish and then the PHP code is back.

Workaround for the moment is to embed everything in the index.php source. 🙂

---

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [March 24, 2025, 12:24pm UTC](https://forums.realmacsoftware.com/t/include-disappearing-php-code/46839/3 "2025-03-24T12:24:42Z")

</div>

Hi @tpbradley, Is this one fixed as well as part of the PHP transcribing fix or is it a separate issue?

---

<div class="post-metadata">

**Author:** ![tpbradley](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/tpbradley/32/25503_2.png) [@tpbradley](https://forums.realmacsoftware.com/u/tpbradley)\
**Post date:** [March 24, 2025, 12:52pm UTC](https://forums.realmacsoftware.com/t/include-disappearing-php-code/46839/4 "2025-03-24T12:52:02Z")

</div>

> [@logrunner](#):
>
> Is this one fixed as well as part of the PHP transcribing fix

Yes it’s possible. I’m having a little trouble following exactly what you’re doing here. However, I’ve tested a few things and can verify the following.

> [@logrunner](#):
>
> Is including PHP code supported?

Yes, you can have php files in the component templates/include directory.

> [@logrunner](#):
>
> Is nesting includes supported?

Yes, you can nest an include within another include and this also supports `@portal()` statements.

---

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [March 24, 2025, 5:20pm UTC](https://forums.realmacsoftware.com/t/include-disappearing-php-code/46839/5 "2025-03-24T17:20:42Z")

</div>

Hi @tpbradley - This is now working as you outlined above. Many thanks. 👍
