Welcome to WebmasterWorld Guest from 54.167.216.93

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

pulling additional php from DB. is this possible?

     
8:59 am on Oct 23, 2007 (gmt 0)

5+ Year Member



Is it possible to print some php into a page header in the same way that we can print html or xml?

For example:
In a content management system the user has the ability to create pages, they populate the content, the page title, meta data, and advanced users have the option to write some php which can be included with the rest of the php code in the page. All of which is stored in the database

Before declaring a doctype on the front end there are a number of php functions to gather the content for a specified page, which is then printed in the required area, wether that is in meta content or between the body tags.

Back to the original question then -
before I close my php and declare the page doctype, how do I print any additional php that may be in the DB for this page

I've tried

/////////////////////////////////////////////////////////////
// IMPORTED CODE ////////////////////////////////////////////
print '?><?php '.$gotContent['CODE'].'?><?php ';
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

but I then see this code instead of it being absorbed as part of the php

9:07 am on Oct 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



print '?><?php '.$gotContent['CODE'].'?><?php ';

Is it not possible to just print what you want? Why open and close many PHP tags?

Can't this do the job for you?
<?php print $gotContent['CODE'];?>

Habtom

9:19 am on Oct 23, 2007 (gmt 0)

5+ Year Member



thats what I tried at first but it just prints the content in the header, again instead of absorbing it as part of my php
9:19 am on Oct 23, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Have a look at eval() [php.net].

Remember that php is a server-side language - when you print, you're just placing content into a document to transmit to a browser - the interpretor doesn't look at it.

9:23 am on Oct 23, 2007 (gmt 0)

5+ Year Member



that's the ticket

thanks guys

it was one of those questions which was difficult to search for answers on

 

Featured Threads

Hot Threads This Week

Hot Threads This Month