![]() |
no "include"s inside classes?
Hello everyone,
I just started with OOP and classes and I placed all gets and sets inside an include file and when using the php include keyword get the following error: Parse error: syntax error, unexpected T_INCLUDE, expecting T_FUNCTION in D:wampwwwform_generatorclass.forms.php on line 187 So, we can not use include files inside a class? Thanks in advance for all the answers, pipesportugal |
Can you post lines 185 thru 189 for us to take a look at? You can include a file from near anywhere, and definitely from inside a class.
-m |
He's probably including the files after his variables.
|
Hi Thank You so much !
this is what I've done: include("includes/class_form_sets_e_gets.php"); My logic (which can be wrong newbie logic, of course) was that should be placed after the ending of the function __construct. Still, I've tried to put it in several different places, beginning, end of the class, etc The names seem to be all correct. pipesportugal |
It has to be inside the __construct(); -- Classes are wrappers for a collection of properties and methods, all code constructs that are part of them have to be part of one of those methods (the functions) however, and not out and about on their own.
-m |
You cannot include (or do very much else at all) directly within the body of the class definition, but you can inside methods.
PHP Code:
|
Hi thank You so much, I appreciate Your help !
So the way You explained it to me, the problem is solved. but..., if this is a free (but respectful) opinion forum: It doesn's have so much logic about it, does it? An include is a perfectly neutral and static instruction no matter where it is placed. Since I like to have all my properties defined at the class for a reason of self organization, my cry for help now is where do I put my 23 properties all with: public function setAction($action) { $this->action = $action; } public function getAction() { return $this->action; } It fills up my class text space. In order to see/correct all the other functions, I must scroll and scroll. When I started working with c# some weeks ago, there was a feature at the visual studio editor very nice which was the possibility of puting 2 marks, one at the beginning and other at the end of the text we wanted to hide, and then we could hide it (it was there, but You couldn't see it, You could see only the mark). I am presently working with editplus editor which in my opinion is great because it's very light on weight and does what I need an html/php editor has to do, but doesn't seem to have this feature. Which way can I go ? Answering this thread is now, not so important as at the beginning, as there are no errors to solve, but I sure would appreciate some suggestions from the most experienced colleagues. Cheers all, pipesportugal |
I'm not so much an experienced colleague as more of a rat bastard novice, but it sounds like you may want to check out Dreamweaver. I don't know if Zend does that, but I know for a fact DW does, and all you have to do is select the lines you want 'compressed' and click in the gutter. Honestly though I hardly ever use it myself, but then most of the classes I'm working with in my current project are only 2-400 lines in length, and I've found documenting phpDoc style has really helped with the organization.
-m |
Zend support "code folding" as they call it to, if you have a function, you can folk it op, just like in Visual Studio :)
|
| All times are GMT. The time now is 02:52 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0