PHP Code ?

Posted on 2012-09-03
Medium Priority
Last Modified: 2012-09-25
I have this line of code in one of my php files, I receive an error the directory on line 108 can't be found.  I'm new to PHP, and not sure which directory this represents:

require $this->classes[$class];
Question by:Jack_son_
LVL 17

Assisted Solution

OmniUnlimited earned 400 total points
ID: 38362279
Just echo it to see the directory and file that the error is occurring on:

echo $this->classes[$class]; 

require $this->classes[$class];

Open in new window

LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 800 total points
ID: 38362451
$this is a key word used in OOP code: it refers to the actual object itself and in your case this means that classes[$class] should be a value set in the initialization code or in a config file. Since you say you're new to php, I think you grabbed that code somewhere and you're trying to use it in a wrong way. Could be more descriptive and tell us what exactly is that code?
LVL 60

Assisted Solution

by:Julian Hansen
Julian Hansen earned 400 total points
ID: 38362652
Can you post the exact error message and also some more code to give a context.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 38364614
i have a test php app, trying to put back together.  It shows no such file or directory on line 108, the above was line 108, so trying to figure out the location of that directory.
LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 800 total points
ID: 38364669
As said in comment ID: 38362451, $this->classes[$class] is a class property wich evidently should hold a directory.

 Try to echoing the property as suggested by comment ID: 38362279

echo $this->classes[$class];

require $this->classes[$class];

You can also try to look for a config.php through the application directory (it could be a folder called 'config' or 'setup').
As I said before, that property could (or should) be initialized when you create the object: in this case, you should look for the file where that object is created (maybe index.php if you just tried to run the app and you got this error) and look for the line where the object is created.

If you tell me how the object is called, I can be more precise suggesting what code you should look for.

LVL 111

Accepted Solution

Ray Paseur earned 400 total points
ID: 38367501
I receive an error
Please show us the EXACT text of the error message.  If you have this code on a public server, please post the URL that can be used to see the error message.

If you're new to PHP but have an extensive programming background in other languages, you may be able to get up to speed on the OOP parts of PHP by reading here:

If you do not have a deep background in other programming languages and you're starting programming by learning PHP, jumping into object-oriented programming might be the "deep end" of the pool.  You might want to start by learning the conventional notation and syntax used to write program code in PHP.  For that, this book is great place to start.  Give yourself a month or two to work through the examples, and you'll be ready for the object-oriented programming at any level of immersion!

Best of luck with your project, ~Ray

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question