keeB Posted April 10, 2007 Share Posted April 10, 2007 Hello, I want to load a class from a file, and I have tried to do so with little success. Here's a sample of my code: include("CMWebServiceImpl.class.php"); $fs = new filesystem(); $data = $fs->readFile("/home/keeb/test.res", "r"); $x = new $data("http://192.168.2.37/services/Router?wsdl"); This returns Fatal error: Class 'CMWebServiceImpl ' not found in /home/keeb/projects/php/cmsService/classes/classFromFile.php on line 10 However, this is not the case, since I can call with success: $y = new CMWebServiceImpl("http://192.168.2.37/services/Router?wsdl"); Anyone do anything like this before? Thanks, - Keeb Link to comment https://forums.phpfreaks.com/topic/46464-loading-a-class-from-a-file-dynamic-class-loading/ Share on other sites More sharing options...
keeB Posted April 10, 2007 Author Share Posted April 10, 2007 bump Link to comment https://forums.phpfreaks.com/topic/46464-loading-a-class-from-a-file-dynamic-class-loading/#findComment-226272 Share on other sites More sharing options...
per1os Posted April 10, 2007 Share Posted April 10, 2007 $x = new data("http://192.168.2.37/services/Router?wsdl"); As long as the class name is data, it shouldn't have the $ infront of it. Link to comment https://forums.phpfreaks.com/topic/46464-loading-a-class-from-a-file-dynamic-class-loading/#findComment-226275 Share on other sites More sharing options...
Glyde Posted April 10, 2007 Share Posted April 10, 2007 The class name isn't data, the class name is CMWebServiceImpl, from what he showed. CMWebServiceImpl is stored in $data. However, from the error that you are showing us, it looks like $data is stored with an extra space at the end. It is actually: "CMWebServiceImpl " instead of "CMWebServiceImpl". Check that variable and I'll get back to you. Link to comment https://forums.phpfreaks.com/topic/46464-loading-a-class-from-a-file-dynamic-class-loading/#findComment-226291 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.