473,606 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Include files along with __autoload function

realin
254 Contributor
hiya guys its been long since i posted here ..

well i am using pattemplate which is a template tool for website development. But in my website's structure i have placed all my classes into a folder called classes that lies in the root. Now to ensure that they are handily available i am using the __autload function from php, like :
[PHP]
function __autoload($cla ssName)
{
if (!class_exists( $className, false))
require_once (dirname(__FILE __).'/../classes/'.$className.'. php');
}[/PHP]

the issue which i faced here is that, now when i include the files from pattemplate folder, it is able to get the single include file to start with but the helping files which are present in the pattemplate folder are not included. It again searches it in the classes folder cause of __autoload thing..

Is there a way out guys ? so that i am able to use the above function which automatically loads files and also let me include the other files ..
Mar 19 '08 #1
3 1578
dlite922
1,584 Recognized Expert Top Contributor
hiya guys its been long since i posted here ..

well i am using pattemplate which is a template tool for website development. But in my website's structure i have placed all my classes into a folder called classes that lies in the root. Now to ensure that they are handily available i am using the __autload function from php, like :
[PHP]
function __autoload($cla ssName)
{
if (!class_exists( $className, false))
require_once (dirname(__FILE __).'/../classes/'.$className.'. php');
}[/PHP]

the issue which i faced here is that, now when i include the files from pattemplate folder, it is able to get the single include file to start with but the helping files which are present in the pattemplate folder are not included. It again searches it in the classes folder cause of __autoload thing..

Is there a way out guys ? so that i am able to use the above function which automatically loads files and also let me include the other files ..
i'm not sure i'm getting what you're saying.

The autoload function gets the files that you are including (such as the pattemplate ones) but not the ones that pattemplate is including?
Mar 21 '08 #2
realin
254 Contributor
thanks mate,

that is why i dropped the plan using patTemplate, will stick to smarty now ;)
Apr 9 '08 #3
dlite922
1,584 Recognized Expert Top Contributor
thanks mate,

that is why i dropped the plan using patTemplate, will stick to smarty now ;)
SMARTY is the way to go! Since i've used it, I feel sick when I echo something in a XHTML page. Just feels so weird and wrong!

DM
Apr 9 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

43
5070
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script. In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these...
14
2151
by: Berislav Lopac | last post by:
With the advent of PHP5, with its OO support and the new __autoload function, I was thinking of implementing some king of scheme to organize classes in such a way that they can be easily found by the __autoload function, yet at the same time would have clear organization of classes. Currently (in PHP4) I'm using a Java-like scheme, borrowed from ActiveLink IORCA (www.active-link.com), which uses a special import() function and classes...
9
2310
by: Tom Cat | last post by:
Is there anything wrong with using a lot of include files? On one part of my website, I have a form. The page it posts data to, includes a different file based on some of the values. The include files also include other pages based on different values. All of these work together to select the right information from the database and display it in the correct format. I'm just wondering if it is better to put all the code in one file...
2
1919
by: Antimon | last post by:
Hi, I'm working on a new web application (php5.1 + postgresql) and i wanted to have seperated files for each class and use __autoload and i have everything split to classes now. This makes my pages need to include a lot of files each request. Do this a huge overhead? I mean shall i go for gigantic function definition scripts and include all of them at once? BTW, my classes are not too big, 4-5 methods and properties each, i thought...
4
3078
by: Kevin Newman | last post by:
The primary problem I've had with php is the lack of namespaces, which makes OOP very difficult to organize, since you end up with large number of classes cluttering up the same namespace - which leads to a secondary problem involving php's __autoload feature. Since you cannot specify a namespace when calling a class that may not have been included, you are forced to store all of your classes in the same folder in your file system. This...
5
2219
by: Tio | last post by:
I have project in MFC(vc++) . There are files and classes: classes:dialog1,dialog2,aaa,bbb ---------------------- main.cpp --------------------- #include "mainfrm.h" #include "dialog1.h" #include "dialog2.h"
3
1763
by: ooba gooba | last post by:
After doing some work in both Java and ASP.NET, I came back to add some major enhancements to a PHP 4 application I built several years ago. A lot of the database access is currently sprinkled throughout the application. In the Java and .NET worlds, I would do data access code by creating classes that would handle all of the data access for each of the application data entities. This worked great and kept all the data access in one...
2
4376
by: David T. Ashley | last post by:
Hi, In my PHP code, I typically break my functions into groups (usually based on the data type they operate on), and then include the files, i.e.: require_once("string_functions.inc"); require_once("large_integer.inc"); etc. The included files never contain any code that gets executed directly (it is
2
1968
by: Ixiaus | last post by:
I was curious (and have spent an enormous amount of time on Google trying to answer it for myself) if Python has anything remotely similar to PHP's SPL __autoload() for loading classes on the fly?? After digging through docs I feel doubtful there is such a language feature, but, it is possible I missed something or maybe someone has written an extension?!? Thanks in advance!
0
7942
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8429
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8084
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8300
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5963
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2443
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1550
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.