Jump to content

Nesting includes(); within Database Information


SharkBait

Recommended Posts

 

In my blog software (custom built) I am curious if I enter <?php include('somefile.php'); ?> within the body of the post that gets put into the database.

 

When it is displayed it won't necessarily display that file correct?

 

I would I assume have to something like bbcode [require]sometime.php[/require] and have the php process it when it sees [require][/require]

 

I'm trying to make it so I can add little modules that I can display different things (like polls) within my content posts etc.

 

:)

I'm not entirely sure what you're doing, but if you store some php script in a DB and then pull it out and have it processed as a PHP script then it'll evaluate like you expect.  On the other hand if you pull it from the DB and treat it like a string (that is you don't evaluate it) then you're correct in assuming the include will just print on-screen.

 

I think a better solution to your module idea is to store a marker or some set of relevant data in a table and have an object (or script) run with that data on display time.  This would complicate your process by adding steps between pulling the data from the table and displaying it, but it would make for more reusable (and perhaps secure) code.

  • 4 weeks later...

I know this is a little late in terms of a reply, but eval() is your friend.  I think I was looking for the ability to parse php after pulling it out of a database for too long.  I knew what I wanted it to do, but didn't know what it was called, and people had no idea what I was talking about, but yea.. eval() is definitely useful.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.