is there anyway to seperate the logic that php has into little "beans", per sae, and include them in your pages where necessary?
Sam
- i know in java you can, but php?
| SitePoint Sponsor |



is there anyway to seperate the logic that php has into little "beans", per sae, and include them in your pages where necessary?
Sam
- i know in java you can, but php?





DLG...PHP has a built in "include" function that rules. The syntax is <?php include("filenamehere.txt") ?>
Make sure that if the included file contains php code that the PHP delimiters ( <?php ?> ) are in there or it won't run.
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes



that's freaking powerful!
man! you can make "php business objects" and re-use them within your site several times!!!!!!!!!!!!
WOW! I work in an e-business group and let me tell you...an app that can do this using java cost us a little over a million.
Sam





Wow! is right call me next time you need a little app like this!![]()
Please don't PM me with questions.
Use the forums, that is what they are here for.





LOL @ freddy...remember I told him about it Freddy, so I get 10%...
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
hi DLG_1
The way I use include in php is:
to hide the access to mySql in another branch and directory of the site.
to control the font, size and other attributes from a single file.
and here is the neat one. i wrote a site in html, complete with tables and then cracked it into three parts. the first part was the header and the left col. the center col (which varied per page - dynamically) contained the data for that page. and a right col that held the banners that would appear on any of the pages. the "pull" for this came not from the top or bottom but from the middle. based on what it was doing, a header + left were selected and a right col (or no right col) were picked.
i share.
Ed Shuck
www.noevalley.com





A million? Sounds like it might be a bit of a rip-off, unless there's something else I'm not "getting" about it.
Better yet is to pull the data out of an SQL database - I could be wrong, but I think that's a more efficient method, partly because it's easily backed up/manipulated.
And yes, I do the same thing edshuck does - I have a "connect.inc" type of file I keep in a directory that you cannot access from the web, and simply include it.
I too use the include function to keep sensitive info outside of the web accesible folders.
I thought pretty much every language had an include or something similar though?
Karl Austin :: Profile :: KDA Web Services Ltd.
Business Web Hosting :: Managed Dedicated Hosting :: From £250/m
Personal Web Hosting :: Budget Web Hosting :: From £50/y
Call 0800 542 9764 today and ask about our Cloud Hosting Platform



the application is called ATG Dynamo 5...and yes it does more than what I specified it does...
So I guess what you guys have done is:
within php code you had some echo's that printed out parts of html...
<header info>
<body>
<footer info>
right?
then within an html page you add some logic to pick which <header info> file you would like to display???
Sam
Hi Sam
I want to get back to what you want to know. But that question may have been lost by now.
My page is essentially 4 pieces. A font, top, bottom and middle.
The font defines all of the font styles, sizes, colors, etc. Kind of like a css. But not depending on the viewer using later browser versions.
then there is the top. this contains the header, a mail box gif, an Amazon ad, and the left menu. It also starts the <body> and leaves a table open, ending the left menu with a </td><td>.
then the body, for the front page this is just some <p> and <hr>
then the end of the process is the bottom which begins by ending the data cell with a </td>.
finally after some closing of the table, the body and html are closed.
the key is that the only thing sent to the inquiring browser is the finished html code. (or the notice of a parse error or other error code.
there are many wonderful things done by php but one is that dynamic code need not be just for css capable browsers. this is a real benefit.
the single generator for my category pages uses the mySQL to fill in the data for about 90 unique pages. Normal process time is .02 sec. (there are maybe 90 uniquely different)
a second or third generator could be written for alternate views of the data and better use of the data.
but even now, a single piece of data with multiple categories is used in more than one instance.
peace
ed
Ed Shuck
www.noevalley.com



in short, you have a php file(index.php) that has some logic that cherry picks what information will be displayed.
right?
Sam
Hi
That is how I am currently using it but i am adding some of the computational power of the code.
One of the things I will be doing with it is collecting eMail addys and then notifying those of events. For example I have a lost pet page that a person can sign up for and then when a pet is lost in the community, the list will be eMailed. The process is currently working but i need to make it display only one eMail at a time and then activate the process. I will be using very similar software for the garage sale, tag sale listings. These are direct visit generators. Oh, and the garage sale item will auto generate a list of all my garage sale items on thrusday night (midnight).
so i am using it as a picker but not for long.
peace
ed
Ed Shuck
www.noevalley.com



okay! hold on!
I'm trying to include() some php3 script...it isn't working!
when I write:and the news.inc is==>Code:<?php> include("news.inc"); ?>
the script will print out everything in my include file...when I don't have the <?php> ?> in the include file...but when I include those tags within the include file I don't get anything.Code:if ($name == ""){ echo " <p><img src='oSquare.gif' width='7' height='7'> Does reaching millions of new customers in less than 45 days make you smile? It did Shivani Gems. [read more]</p> <p><img src='oSquare.gif' width='7' height='7'> Read how DLG Solutions helped EJGold.com with a new online stores </p> "; } else { echo " "; } if ($status_report) { echo " <p><img src='oSquare.gif' width='7' height='7'> $status_report </p> "; }
can I only have html in an include file? or can I also have php3?
please help!
Sam





Well is your server set to parse .inc files as php, try naming it news.php3 or news.php however you normally name php files then use. The reason is because with the <? ?> tags around it the server doesn't know what to do with .inc files so when you take them out it just displays the code.
include("news.php3");
Please don't PM me with questions.
Use the forums, that is what they are here for.





Well, you can definitely have PHP in an included file - I do it all the time. I think you SHOULD be able to use PHP code in a .inc file if it's included, that is, but obviously either you cannot, or for some reason your server doesn't allow it. I'd go with what Freddy said - I do the same thing now just in case (name almost all of my includes with a .php extension).



got it!
turns out that within the included file I had
<?php> instead of <?php and it was choking!
so now I have
<?php
include("news.inc");
?>
voila!
Thanks.
Sam
![]()



can one include a php file from within another included file?
include("hi.inc");
hi.inc ==> blah, blah include("greeting.inc");
?????
Sam





Yes but beware the more includes inside of includes that you have the slower your performance will be
Please don't PM me with questions.
Use the forums, that is what they are here for.
Back on the original post, there is a difficulty that i did not notice.
<? php3>
should be <? php3 and is finally closed with the ?>
Perhaps this is answered in the intervening replies. Following are some working includes from my page.
I am not sure whether or not you are still having a problem but if you are, can we start again.
peace
Ed Shuck
www.noevalley.com
Bookmarks