I've been doing some level of PHP programming for many years now, and
have in the past few months started implementing lots of the core PHP5
features into a new project, when I noticed some interesting issues
with objects and classes.
I'm having some problems with Object Oriented PHP5, namely when a class
isn't defined correctly no errors are produced during object
instantiation. For example if a method which violates a global
namespace is defined inside a class I cannot get PHP to throw an error
when that class is instantiated. PHP will catch simple errors such as
lines not ending in semicolons, but doesn't catch these more 'global'
issues.
Worst of all, in my example where I violate the namespace, the program
fatally dies and does so silently.
If anyone else has experienced this issue, or if anyone knows how to
get these types of errors to report themselves, it would be much
appreciated.
I'm sure this has been covered before and I just couldn't find the
answer to my question on the board.
Again, any help is much appreciated.
Thanks,
Nate 6 1436 n8*****@gmail.c om said the following on 09/04/2006 00:44: I'm having some problems with Object Oriented PHP5, namely when a class isn't defined correctly no errors are produced during object instantiation. For example if a method which violates a global namespace is defined inside a class I cannot get PHP to throw an error when that class is instantiated. PHP will catch simple errors such as lines not ending in semicolons, but doesn't catch these more 'global' issues.
What do you mean "a method which violates a global namespace?" Can you
give an example?
--
Oli
class TestClass
{
public function list(){
echo 'list';
}
}
`list` is a built in PHP method, so by declaring it in an object, it
violates the global namespace. php won't complain about this method
being in the class, until you try to instantiate it as an object. then
it will just fatally fail silently.
Nate said the following on 09/04/2006 02:03: class TestClass { public function list(){ echo 'list'; } }
`list` is a built in PHP method, so by declaring it in an object, it violates the global namespace.
list() is actually not a function/method, but a language construct, and
as such, doesn't belong to any namespace.
Use of language constructs as method names is not allowed, however, use
of "global" function names is, replace your "list" example with "count",
for example.
php won't complain about this method being in the class,
Yes it does, if you have errors set appropriately. With E_ALL, I get
the following message:
Parse error: parse error, unexpected T_LIST, expecting T_STRING ...
--
Oli
I guess I really shouldn't use the term namespace, I suppose what I
meant was reserved names, or things PHP has already used so it doesn't
want you to use them.
So, I'm still having the issues I described and my error level is set
to E_ALL as well according to my php.ini file.
I'll look more into my error reporting setup, but for now, using
language constructs in objects causes my setup to fail silently with
errors set to E_ALL, but it's nice to know that PHP will catch these
errors if setup correctly and that objects can have methods whose names
are the same as global function names.
Nate wrote: I guess I really shouldn't use the term namespace, I suppose what I meant was reserved names, or things PHP has already used so it doesn't want you to use them.
So, I'm still having the issues I described and my error level is set to E_ALL as well according to my php.ini file.
I'll look more into my error reporting setup, but for now, using language constructs in objects causes my setup to fail silently with errors set to E_ALL, but it's nice to know that PHP will catch these errors if setup correctly and that objects can have methods whose names are the same as global function names.
I'm afriad you'll need to provide the actual code that causes the
problem, as well as the precise version number of PHP.
Using a reserved keyword would cause PHP to fail at the parsing stage,
so the scenario you described shouldn't happen. Also, names of global
functions are available as method names of a class.
On 9 Apr 2006 15:19:40 -0700, "Nate" <n8*****@gmail. com> wrote: So, I'm still having the issues I described and my error level is set to E_ALL as well according to my php.ini file.
The error reporting can overridden by a error_reporting () call. You
might want to make sure you don't have one of those (or alternatively
put one in and set it to E_ALL).
You definately have something wrong with your error reporting. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: oj |
last post by:
Could someone explain to me why the following code snippet throws an
"Object Reference not set to an instance of an object error":
public void SetActiveStaffMember(int staffMemberId)
{
DAL.StaffMemberDataSet smDS = new DAL.StaffMemberDataSet();
|
by: Ram |
last post by:
Hi Friends
I want to develope a custom control in .net which can be used with any
project. I am writing a function in that class which I want to take any
object as parameter. For that I have used Object class as parameter.
Now it can take any object as its parameter. But the problem is that I
want to access the values of the private or public member variables of
the passed object, for which I may have to typecast the Object class...
|
by: Aryan |
last post by:
Hi,
I am implementing Business object, but while implementing this I
want to have DataTable or DataSet as part of Business Object. For
example, I want to bind controls directly to these Business Objects. So
please suggest me how can I achieve this??
Is is good to create a Property in Business Object which will have
return type as "DataTable / DataSet"?? or what could be the optimum way
to achieve the same.
|
by: mak2045 |
last post by:
I copied a form (Microsoft 2000 with Visual Basic 6.0) that had a procedure behind the text box and renamed it. I did not get an error message, but the new form that I thought I created did not appear. So, I copied it again. As a result, the object class was created and still exists but the form does not. I tried to delete that object that corresponds to the form name that does not exist, but I am unable to do so.
Please let me know what...
|
by: mikie |
last post by:
somebody asked me a question:
string is derived from object class, right? (i said yes)
so how it could be object class declares method returning string?
thanks for any explanation / link / whatever :)
mikie
| |
by: iavian |
last post by:
<?php
interface Pizza {
public function getPrice();
}
class Margherita implements Pizza {
private $cost = 4.50;
|
by: Logos |
last post by:
I have what may be a bug, or may be a misunderstanding on how pass by
reference and class inheritance works in PHP. Since I'm relatively
new to PHP, I'm hoping for a little outside help to shed some light on
this!
(code abbreviated for clarity)
I have a parent class, DetailCollection, with a child class
KeycodeTracker:
|
by: ced69 |
last post by:
having trouble getting marquee to work get object required errors
tring t <title>This Month at the Chamberlain Civic Center</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<script src="Dunbarlab9.js" type="text/javascript"></script>
<script type="text/javascript">
|
by: pjerald |
last post by:
Clear me friends.
Object class is the base class for all classes. Thus the methods with protected access in the object class can be invoked by any object(Of any class).
I know the statement is wrong!.
But i cannot convince myself(Since i don't know it clearly).
Shed some light.
|
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,...
|
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...
| |
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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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
| |
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...
| |