Re: [PHP] Object Overloading in PHP5

2004-08-29 Thread FrzzMan
Daniel Schierbeck wrote:
Stefan wrote:
It's a bug.
 * Siehe http://bugs.php.net/bug.php?id=28444 ... und ...
 *   http://news.php.net/php.bugs/63652
A workaround is possible using __call( $name, $args) { return( 
$this-__get( $name)); }. But it sucks, since constructs using array 
indices are impossible as $obj-not_existing_attr()[0]

regards
Daniel Schierbeck wrote:
Do you guys have any idea why this code:
?php
class Foo
{
private $elem = array();
public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
trigger_error(Property '$prop' not defined, 
E_USER_ERROR);
}
}
public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}

$obj = new Foo;
$obj-a = new Foo;
$obj-a-b = Foobar;
?
returns this:
Fatal error: Cannot access undefined property for object with 
overloaded property access in ... on line 24

Where line 24 is:
$obj-a-b = Foobar;
?
%!#%%(/)((%%!#%%#!%#!
Calm down, calm down... it's not good for your health :D
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Why won't my echo won't work? [newbie question]

2004-08-29 Thread FrzzMan
John Nichel wrote:
[EMAIL PROTECTED] wrote:
The first two of these 3 echo statements work. But my last echo 
doesn't. 'username' is the name of the element I want to echo. To the 
right of each is what I see echoed.

echo $_SERVER['REQUEST_METHOD'];  echos - POST
echo $_POST;  echos - Array
echo $_POST['username'];  echos - nothing
How are you setting $_POST['username']?  Let's see the code for the form.
Members in $_POST array are set (mostly) by submitting a form with POST 
method, make sure your form is not submitting by GET.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Dynamic HTML Creation

2004-08-29 Thread FrzzMan
Sam Hobbs wrote:
Ramil Sagum [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Ah. You should have said this in your first mail (which was
confusing). It now becomes clear. I think what you are looking for is
a template engine, like smarty
http://smarty.php.net/

If Smarty is a good solution that the other osCommerce users and developers
agree is useful, then yes, I should have said more in my original question.
If however Smarty is not a good solution for osCommerce, then explaining
that I am modifying osCommerce would have been confusing and distracting.
I like the idea of separating the UI from the program. Programmers and
software designers have been doing that for many years. It is usually easier
to keep the UI separate from the processing and then have tags of some type
in the UI that allows the processing to put data into the UI and pluck it
out. That type of thing can be done using HTML too. There are some
disadvantages of using HTML and the DOM but I suspect there are limitations
of Smarty too. If it is possible to use HTML and the DOM then there are
significant advantages to using an existing standard that is in common use.
If a web site is hosted in a server owned by someone else and if the
server's owner (which includes the employees) must install Smarty befor it
can be used, then that is a critical disadvantage of Smarty.
So do you know of specific advantages of Smarty compated to using the HTML
and DOM standards? Without spending a lot of time to learn Smarty, it is
difficult for me to see the advantages.
Smarty is a template engine, you can download it and embed it in your 
application, it's not necessary to 'install' it on the server.

I suggest you read some overview of Smarty, you'll get the idea really 
fast. It's easy to understand...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: attaching a custom icon to a file on server side

2004-08-29 Thread FrzzMan
[EMAIL PROTECTED] wrote:
I want to attach a custom icon to a dynamically created text file on the 
server-side

when the user downloads the file to his desktop, there is a custom 
icon...ico file attached to it...

is this possible ?
g
nah, you can't embed binary data (icon file) into text file...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] User email changes verification strategy?

2004-08-29 Thread FrzzMan
Hello,
I'm adding some verification into my user database manager. After a 
while I come up with some ideas about asking user to verify their email 
address when they change their email address.

But, the strategy is a lil confusing for me.
When they change the email address. Where should the verification code 
be emailed to? Of course it's not the new addy, but what will happen if 
their old addy became unusable (so they change), can you guys come up 
with some ideas? I'm confusing...

TIA
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] SOAP speed

2004-08-28 Thread FrzzMan
Hello,
I'm developing some site that will share the same UserDB, because these 
site are quite large in scale so I decided to host it on different servers.

Each site will have it own cache of active user on the site, so the user 
wont' have to be authenticated every request (will be a pain in the a$$ 
I'm sure), the cache will be cleared when the session time out.

But since I don't have much experience with these kind of distributed 
authenticate process with SOAP, so I wonder how long it will take to 
receive the response from the UserDB server using SOAP.

There's a change that the site server will be located @ Europe, while 
the UserDB server will be located @ US (for global access).

If the transmission time is about 1, 2 or even 3 secs, I think it 
acceptable. btw, do you have any experience about this?

TIA
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] recompile your PHP installation with --with-mysql optio

2004-06-21 Thread FrzzMan
Why did you set the dir to /usr/local/sql???
Did you have mysql there??? It's not the normal installation dir of mysql...
Long P Nguyen wrote:
I recompiled PHP with --with-mysql=/usr/local/sql and still got the following errors:
Checking PHP configuration settings
PHP version... success [4.2.2]
DOMXML extension... success [2.4.23]
MySQL extension failure [required-extension not installed] 

recompile your PHP installation with --with-mysql option 


-Original Message-
From: John Nichel [mailto:[EMAIL PROTECTED]
Sent: Monday, June 21, 2004 1:58 PM
To: php-general Mailing List
Subject: Re: [PHP] recompile your PHP installation with --with-mysql
option
Nguyen, Long P (Mission Systems) wrote:
How do you recompile your PHP installation with --with-mysql option??

In the PHP source tree
$ ./configure --with-mysql[=dir] --with-other-options
$ make
$ make install
I'm sure this will bring a few questions. ;)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] protecting your source code?

2004-06-14 Thread FrzzMan
Surely you can't include files that way, that php file will be process 
and you will end up include its result. Try include using file system 
path instead, it will work...

About your question about source code protecting, try Turck MMCache, 
it's a optimizer (the best I known) plus it have encode ability... 
finally, it's free :P~

Edward Peloke wrote:
Thanks James,
I have played with the Zend IDE a little...but will take a look.  On a
simpler scale, I usually have one main directory which then holds the
subdirectories for classes, header, etc. then use includes to pull in
header, classes, etc.  I tried to call my classes from an external folder
but can instantiate them..why?  I seem to be able to pull them in...example
include_once(http://www.peloke.com/myfolder/src/classes/classname.class.php
);
but when I try to instantiate it, get an error that I can't
$classname=new Classname();
Why?
Thanks,
Eddie

-Original Message-
From: James Harrell [mailto:[EMAIL PROTECTED]
Sent: Monday, June 14, 2004 3:55 PM
To: Edward Peloke; Php-General
Subject: RE: [PHP] protecting your source code?
Hi Edward,
Check out the Zend Encoder: www.zend.com
To run encoded/compiled programs, the server will need the (free)
Zend Optimizer, available for download at the same location.
Zend has a small-business program that if your yearly revenues are
less than some magic number, you get a major discount on the Zend
Suite which includes the encoder and the development environment.
The Zend Development Environment is fantastic- includes a debugger
and profiler, code completion, etc. After 10+ years as a vi-guy, I
actually made the switch recently. :)
James

-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]
Sent: Monday, June 14, 2004 3:50 PM
To: Php-General
Subject: [PHP] protecting your source code?
I wrote a bunch of code that will be used for a local site.  I usually do
all my hosting with a friend who I trust...the new site will be hosted by
another company in town (not my choosing) who I don't necessarily trust to
not copy the code and reuse it for other sites.  How can I protect the
code?
I know there are some encoders but I have never used them.
Thanks,
Eddie
WARNING:  The information contained in this message and any attachments is
intended only for the use of the individual or entity to which it is
addressed.  This message may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  It may also
contain trade secrets and other proprietary information for which you and
your employer may be held liable for disclosing.  You are hereby notified
that any unauthorized dissemination, distribution or copying of this
communication is strictly prohibited.  If you have received this
communication in error,  please notify [EMAIL PROTECTED] by E-Mail and then
destroy this communication in a manner appropriate for privileged
information.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Behaviour of get_class_methods() and get_class_vars()

2004-06-14 Thread FrzzMan
This copy directly from my bug report, someone here do you know any way 
around for this problem.

--
Description:

When get_class_vars() return every properties of the class, private and
protected members are mark with [Class Name] and * before its name, well
it better being mark with + or - or # (like UML standard).
Also, this function shouldn't return value of the property as private
and protected can only be expose in the scope that have access
permission.
Next, get_class_methods() also return every methods the class have,
without any marking method?!?! What's the point doing that if I can't
figure out if I can access the class's method or not.
I suggest these two function should return all attributes and methods
with its access marking.
And another function, maybe get_class_vars_value() to expose default
value of attributes in the class, this function should return value of
accessible attribute, too.
Reproduce code:
---
?php
class ClassA
{
private $PrivateVar = null;
protected $ProtectedVar = null;
public $PublicVar = null;
private function PrivateFunc()
{}
protected function ProtectedFunc()
{}
public function PublicFunc()
{}
}
var_dump(get_class_vars('ClassA'));
var_dump(get_class_methods('ClassA'));
?
Expected result:

array(3) {
  [PrivateVar] = string(1) -
  [ * ProtectedVar] = string(1) #
  [PublicVar] = string(1) +
}
array(3) {
  [PrivateFunc] = string(1) -
  [ProtectedFunc] = string(1) #
  [PublicFunc] = string(1) +
}
Actual result:
--
array(3) {
  [ ClassA PrivateVar] = NULL
  [ * ProtectedVar] = NULL
  [PublicVar] = NULL
}
array(3) {
  [0]= string(11) PrivateFunc
  [1]= string(13) ProtectedFunc
  [2]= string(10) PublicFunc
}
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] [PHP5] Super constructor?

2004-06-13 Thread FrzzMan
Hi guys, hey don't laugh at the subject, in fact I don't what to call 
it, so let's call it super constructor :D

Let's see following code...
class Base
{
__construct()
{
// Do something
}
}
class One extends Base
{
__construct()
{
// Do nothing
}
}
class OneMore extends One
{
__construct()
{
// Do things :D
}
}
So when I create an instance of OneMore class by:
$OneMoreInstance = new OneMore()
The __construct() method of class OneMore will be called, not the one of 
One and Base, right?

So is there any way around to make the Base class have a contructor that 
will be called everytime one of its child initialize?

My problem, I want all of the classes in my object are extend from one 
base class, so they are all have some common properties and function, 
but PHP won't implicit call the contructor (that's the right way)... 
btw, in my case, this is bad, as bad as every constructor would be called...

Well, hope you understand what I'm trying to say...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] [PHP5] Super constructor?

2004-06-13 Thread FrzzMan
Yeah you understood me, thanks god :D but not fully :(
But the problem is right in your code (sorry :D)
What if I create an instance of ChildClass, its constructor won't be 
called (since it commented out), but if I un-comment its constructor, it 
will be called even if I create an instance of GrandChildClass?

Let me make some simple diagram ;)
Class1 -- Class2 -- Class3 -- Class4
If I create an instance of Class4, then Class4's constructor and 
Class1's constructor must be called, neither Class3 nor Class2.

You can see that Class1's constructor will always be called, and the 
constructor of the lowest class in the class tree will be called.

I think this is a bit complex, I can define a final function in Class1, 
and call it in every deriver class constructor, it will solve the 
problem (I think) but it's not convenience, I want it done automatically...

Any idea are welcome :D
Chris wrote:
FrzzMan wrote:
Hi guys, hey don't laugh at the subject, in fact I don't what to call 
it, so let's call it super constructor :D

Let's see following code...
class Base
{
__construct()
{
// Do something
}
}
class One extends Base
{
__construct()
{
// Do nothing
}
}
class OneMore extends One
{
__construct()
{
// Do things :D
}
}
So when I create an instance of OneMore class by:
$OneMoreInstance = new OneMore()
The __construct() method of class OneMore will be called, not the one 
of One and Base, right?

So is there any way around to make the Base class have a contructor 
that will be called everytime one of its child initialize?

My problem, I want all of the classes in my object are extend from one 
base class, so they are all have some common properties and function, 
but PHP won't implicit call the contructor (that's the right way)... 
btw, in my case, this is bad, as bad as every constructor would be 
called...

Well, hope you understand what I'm trying to say...
I'm not positive I understand you correctly, but I think this will 
answer your question.

Example Classes:
class ParentClass
{
   function __construct()
   {
   echo 'ParentClass::__construct()',\r\n;
   }
}
class ChildClass extends ParentClass
{
/*
   function __construct()
   {
   parent::__construct();
   echo 'ChildClass::__construct()',\r\n;
   }
//*/
}
class GrandChildClass extends ChildClass
{
   function __construct()
   {
   parent::__construct();
   echo 'GrandChildClass::__construct()',\r\n;
   }
}
__construct is just like any other method, if you overload it (redefine 
it in a child class), the parent method will not be called 
automatically, so, if you want the functionality of both, you can call 
the parent constructor from the childs constructor. If the direct parent 
doesn't have a constructor, the next parent's constructor is checked and 
so on.

In the above example when defining a GrandChildClass, its constructor 
and the ParentClass::__construct() are will both run. If you uncomment 
ChildClass::__construct(), it will run as well.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] [PHP5] Super constructor?

2004-06-13 Thread FrzzMan
Try var_dump($GrandChildClass) or print_r($GrandChildClass) everytime 
you need to inspect variable content. Not echo...

PS: Hi there Vietnamese guy, same here ;)
Chris wrote:
Because /$GrandChildClass;/ Is an object. So when you go to echo it, PHP 
tries to convert it to a string.

Pham Cong Dinh wrote:
Hi all,
I tested Chris's code:
?php
class *ParentClass*
{
   function __construct()
   {
   echo 'ParentClass::__construct()',\r\n;
   }
}
class *ChildClass *extends ParentClass
{
/*
   function __construct()
   {
   parent::__construct();
   echo 'ChildClass::__construct()',\r\n;
   }
//*/
}
class *GrandChildClass *extends ChildClass
{
   function __construct()
   {
   parent::__construct();
   echo 'GrandChildClass::__construct()',\r\n;
   }
}
$GrandChildClass = new GrandChildClass();
echo $GrandChildClass;
?
It resulted:
ParentClass::__construct()
GrandChildClass::__construct()
Object id #1
Could anyone kindly tell me why the string Object id #1 is printed?
Thanks
Dinh
Chris wrote:
FrzzMan wrote:
Hi guys, hey don't laugh at the subject, in fact I don't what to 
call it, so let's call it super constructor :D

Let's see following code...
class Base
{
__construct()
{
// Do something
}
}
class One extends Base
{
__construct()
{
// Do nothing
}
}
class OneMore extends One
{
__construct()
{
// Do things :D
}
}
So when I create an instance of OneMore class by:
$OneMoreInstance = new OneMore()
The __construct() method of class OneMore will be called, not the 
one of One and Base, right?

So is there any way around to make the Base class have a contructor 
that will be called everytime one of its child initialize?

My problem, I want all of the classes in my object are extend from 
one base class, so they are all have some common properties and 
function, but PHP won't implicit call the contructor (that's the 
right way)... btw, in my case, this is bad, as bad as every 
constructor would be called...

Well, hope you understand what I'm trying to say...
I'm not positive I understand you correctly, but I think this will 
answer your question.

Example Classes:
class ParentClass
{
   function __construct()
   {
   echo 'ParentClass::__construct()',\r\n;
   }
}
class ChildClass extends ParentClass
{
/*
   function __construct()
   {
   parent::__construct();
   echo 'ChildClass::__construct()',\r\n;
   }
//*/
}
class GrandChildClass extends ChildClass
{
   function __construct()
   {
   parent::__construct();
   echo 'GrandChildClass::__construct()',\r\n;
   }
}
__construct is just like any other method, if you overload it 
(redefine it in a child class), the parent method will not be called 
automatically, so, if you want the functionality of both, you can 
call the parent constructor from the childs constructor. If the 
direct parent doesn't have a constructor, the next parent's 
constructor is checked and so on.

In the above example when defining a GrandChildClass, its constructor 
and the ParentClass::__construct() are will both run. If you 
uncomment ChildClass::__construct(), it will run as well.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php