Cant get include to work...

Hi

This may be easy to most of you, but as a newbiw; I'm struggling.

I am bringing in an include into a php file, but cant run the commands
within the include.

As an example, Within my php page I write:

{php}include("content/myinclude.php");{/php}

and the contents of myinclude.php is:

{php}
print "Hello";
{/php}

This is just placeholder text

Then when I view the page in the browser I see that the include is
being brought in but is displayed as:

{php} print "Hello"; {/php}
This is just placeholder text

And the {php} doesn't execute.

I have set both the include and the page it is being brought into as
executable on the unix server it is sitting on.

I am right in saying that the result should only be:

Hello
This is just placeholder text

Aren't I?

Many Thanks

John
johnwebster9865 [ Di, 22 Januar 2008 16:21 ] [ ID #1914010 ]

Re: Cant get include to work...

I wish I could delete this message. Just figured it out. Sorry.
johnwebster9865 [ Di, 22 Januar 2008 16:27 ] [ ID #1914011 ]

Re: Cant get include to work...

On Jan 22, 10:21 am, johnwebster9865 <johnwebster9... [at] yahoo.com>
wrote:
> Hi
>
> This may be easy to most of you, but as a newbiw; I'm struggling.
>
> I am bringing in an include into a php file, but cant run the commands
> within the include.
>
> As an example, Within my php page I write:
>
> {php}include("content/myinclude.php");{/php}
>
> and the contents of myinclude.php is:
>
> {php}
> print "Hello";
> {/php}
>
This is just placeholder text
>
> Then when I view the page in the browser I see that the include is
> being brought in but is displayed as:
>
> {php} print "Hello"; {/php}
> This is just placeholder text
>
> And the {php} doesn't execute.
>
> I have set both the include and the page it is being brought into as
> executable on the unix server it is sitting on.
>
> I am right in saying that the result should only be:
>
> Hello
> This is just placeholder text
>
> Aren't I?
>
> Many Thanks
>
> John

Are you actually writing {php} and {/php} in your code or is that just
for the sake of illustration?
zeldorblat [ Di, 22 Januar 2008 16:28 ] [ ID #1914013 ]

Re: Cant get include to work...

On 22/01/2008 in message
<0d92dd17-3a4d-44bf-b71d-4a767501519f [at] t1g2000pra.googlegroups.com>
johnwebster9865 wrote:

>{php}
>print "Hello";
>{/php}
>
This is just placeholder text

I am new to php as well but I haven't seen that terminology so far.

Shouldn't it be:

<?php
print "Hello";
?>

--
Jeff Gaines Damerham Hampshire UK
This is as bad as it can get, but don't bet on it
Jeff Gaines [ Di, 22 Januar 2008 16:29 ] [ ID #1914015 ]

Re: Cant get include to work...

johnwebster9865 wrote:
> Hi
>
> This may be easy to most of you, but as a newbiw; I'm struggling.
>
> I am bringing in an include into a php file, but cant run the commands
> within the include.
>
> As an example, Within my php page I write:
>
> {php}include("content/myinclude.php");{/php}
>
> and the contents of myinclude.php is:
>
> {php}
> print "Hello";
> {/php}
>
This is just placeholder text
>
> Then when I view the page in the browser I see that the include is
> being brought in but is displayed as:
>
> {php} print "Hello"; {/php}
> This is just placeholder text
>
> And the {php} doesn't execute.
>
> I have set both the include and the page it is being brought into as
> executable on the unix server it is sitting on.
>
> I am right in saying that the result should only be:
>
> Hello
> This is just placeholder text
>
> Aren't I?
>
> Many Thanks
>
> John
>

Are you actually using {php}? Because that's not valid PHP syntax.
To execute PHP you need to start the section with <?php and end it with ?>

Example:

<?php
print "Hello World!"
?>

I would guess that you have been looking at some template engine that
uses {} to mark the beginning of sections, in this case a PHP section
and when parsing the template file the code between {php} and {/php} is
handled accordingly.

- Jensen
Jensen Somers [ Di, 22 Januar 2008 16:36 ] [ ID #1914017 ]

Re: Cant get include to work...

johnwebster9865 wrote:
> I wish I could delete this message. Just figured it out. Sorry.
>

John,

Don't worry about it. We all were beginners at one time. And I'm sure
we've all made similar mistakes! :-)


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex [at] attglobal.net
==================
Jerry Stuckle [ Di, 22 Januar 2008 19:59 ] [ ID #1914029 ]
PHP » comp.lang.php » Cant get include to work...

Vorheriges Thema: Can someone wxplain classes to me please - the why not what or how?
Nächstes Thema: Regular Expression: How the rule is applied for the Pattern