[PHP] gzip functions and error

2005-01-22 Thread Dmitry
Hello!
How disable error messages when i send incorrect data into gzip* extract 
functions, such as gzinflate or gzuncompress?

For example:

function _pack($data) {
 $data = serialize($data);
 $data = gzdeflate($data,9);
 $data = base64_encode($data);
 $data = urlencode($data);
 return $data;
} # _pack()

function _unpack($data) {
 $data = urldecode($data);
 $data = base64_decode($data);
 $data = gzinflate($data);
 $data = unserialize($data);
 return $data;
} # _unpack()

$s = _pack(123); //  K7YytlIyNDJWsgYA
$s = _unpack(K7YytlIyNDJWsgYA); // 123
$s = _unpack(123); //  Warning: gzinflate() [function.gzinflate]: data 
error

How disable this warnings? error_reporting(0) or @ operators does not help 
me.
But I dont want use error_handler functions.

Thanks. 

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



[PHP] Re: Classes and parents.

2005-01-22 Thread Dmitry
Thanks,
but I think that this code more easy.

class a {
 function say() { echo A; }
 function run() { $this-say(); }
}
class b {
 function say() { echo B; }
 function run() {
$a = new a;
$a-run();
}
}

$obj = new b;
$obj-run();

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



[PHP] Re: PHP.ini setup, config, installation recognition?

2005-01-22 Thread David Robley
On Saturday 22 January 2005 18:08, Joseph E. Maxwell wrote:

 Hello,
 
 I am setting up a program that requires allow_call_time_pass_reference to
 be enabled. I've set allow_call_time_pass_reference = ON in the
 /usr/local/etc/php.ini file
 
 grep -n allow_call_time_pass_reference /usr/local/etc/php.ini
 70: - allow_call_time_pass_reference = 1 [Code cleanliness]
 167:allow_call_time_pass_reference = 1
 
 But the program still calls for the option to be enabled. So I have run a
 test file with the ini_get function, the code below. --code---
  html
  head
   titleTest Page/title
  /head
  body bgcolor=#FF text=#00
 ?php echo ini_get('allow_call_time_pass_reference'); ?
 /body
 /html
 end code-
 
 Output page ==  blank
 
 /usr/local/etc/php.ini has permissions set to 444 and listed in
 phpinfo.php
 
 Suggestions?

You don't say whether you restarted apache; this is required to read and
utilise the changes to php.ini.


-- 
David Robley

That does not compute.

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



[PHP] Preg_match----------help

2005-01-22 Thread Chandana Bandara
hi , 

using preg_match , how can i match , _ ,   -  such special characters 
in a sentence  ??? 

Eg:

Strings are like this,

1.Ahgrwgsgd dfjb yuhh dfh ABCD AFGHFDc GHJGKJ -- here i want 
to match  ABCD 

2.AFRYRGH  vhGHJGB ASD_ASD_DER GHJGJ  kjHGKJGK -- here i want to 
match  ASD_ASD_DER

3.GHHTGH GHJK BO-CA JKJ JLKL ---here i want to match  BO-CA 

what is the most suitable way to match those data ? plz guide me ,

Thanx in advance,
chandana



[PHP] end of array

2005-01-22 Thread Jeffery Fernandez
Hi all,
I have a foreach loop on an array and within that loop I need to find if 
the array has reached the last pointer. I have tried

if (next($row))
{
}
but that advances the pointer. Any tips on finding out if the array 
pointer has reached the last element ?

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


Re: [PHP] Preg_match----------help

2005-01-22 Thread RaTT
Hello, 

This regular expresion should help you on your way 

$regex = /[A-z_\-]+?/;

HTH 
Jarratt

On Sat, 22 Jan 2005 17:03:30 +0600, Chandana Bandara
[EMAIL PROTECTED] wrote:
 hi ,
 
 using preg_match , how can i match , _ ,   -  such special 
 characters in a sentence  ???
 
 Eg:
 
 Strings are like this,
 
 1.Ahgrwgsgd dfjb yuhh dfh ABCD AFGHFDc GHJGKJ -- here i want 
 to match  ABCD
 
 2.AFRYRGH  vhGHJGB ASD_ASD_DER GHJGJ  kjHGKJGK -- here i want to 
 match  ASD_ASD_DER
 
 3.GHHTGH GHJK BO-CA JKJ JLKL ---here i want to match  BO-CA
 
 what is the most suitable way to match those data ? plz guide me ,
 
 Thanx in advance,
 chandana
 


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



[PHP] Re: end of array

2005-01-22 Thread Raj Shekhar
Jeffery Fernandez [EMAIL PROTECTED] writes:

 Hi all,
 
 I have a foreach loop on an array and within that loop I need to find
 if the array has reached the last pointer. I have tried
 
 if (next($row))
 {
 
 }
 
 but that advances the pointer. Any tips on finding out if the array
 pointer has reached the last element ?

$n_elts = count($myarray);
for ($i=0; $i $n_elts ; $i++)
{
if ($i = $n_elts -1)
{
echo On last element;
break;
}
else
{
echo Somwhere in the middle;
}
}

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



[PHP] Re: end of array

2005-01-22 Thread M. Sokolewicz
Raj Shekhar wrote:
Jeffery Fernandez [EMAIL PROTECTED] writes:

Hi all,
I have a foreach loop on an array and within that loop I need to find
if the array has reached the last pointer. I have tried
if (next($row))
{
}
but that advances the pointer. Any tips on finding out if the array
pointer has reached the last element ?

$n_elts = count($myarray);
for ($i=0; $i $n_elts ; $i++)
{
if ($i = $n_elts -1)
{
echo On last element;
break;
}
else
{
echo Somwhere in the middle;
}
}
that's an eternal loop in case you hadn't noticed (*rolls eyes*)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: end of array

2005-01-22 Thread Raj Shekhar
M. Sokolewicz [EMAIL PROTECTED] writes:

 Raj Shekhar wrote:

  $n_elts = count($myarray);
  for ($i=0; $i $n_elts ; $i++)
  {
  if ($i = $n_elts -1)
  ^^^
Use of == required to make it work 

  {
  echo On last element;
  break;
  }
  else
  {
  echo Somwhere in the middle;
  }
  }
 that's an eternal loop in case you hadn't noticed (*rolls eyes*)

Oops :( not eternal loop though, only one loop 

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



Re: [PHP] end of array

2005-01-22 Thread Rasmus Lerdorf
Jeffery Fernandez wrote:
Hi all,
I have a foreach loop on an array and within that loop I need to find if 
the array has reached the last pointer. I have tried

if (next($row))
{
}
but that advances the pointer. Any tips on finding out if the array 
pointer has reached the last element ?
end($arr);
$last = key($arr);
foreach($arr as $key=$elem) {
   if($key !== $last) {
  ...
   }
}
That would do exactly what you asked, however, it sounds like if you 
want to do something for every item in the array except the last you 
should just remove that last item before your loop.

$last = array_pop($arr);
foreach($arr as $elem) {
   ...
}
-Rasmus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Classes and parents.

2005-01-22 Thread Jochem Maas
Dmitry wrote:
Thanks,
but I think that this code more easy.
class a {
 function say() { echo A; }
 function run() { $this-say(); }
}
class b {
 function say() { echo B; }
 function run() {
$a = new a;
$a-run();
for starters b doesn't even extend a
and secondly the b::run() method is creating an object
on each invocation - not exactly good use of OO.
besides which b::run() is creating an object of an arbitrary
class, assuming b was supposed to extend a in your example above
the you have hardcoded the parent into the subclass, thats plain wrong...
my example wasn't a specific solution to your problem but an example of 
3 ways to acomplish the goal of calling the version of a method in the 
super class. if you didn't understand something just ask.

}
}
$obj = new b;
$obj-run();
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: multiple sessions on same server/domain

2005-01-22 Thread Marek Kilimajer
Richard Lynch wrote:
Marek Kilimajer wrote:
COKIES, I'm talking about COOKIES.
Anytime you talk about cookies or cookie files, you mean session and
session files, respectively. These are completely different things,
please don't intermingle them.

session_set_cookie_params()
^^^
You're talking about a function whose name starts with session, which is
in the sessions section of the PHP Manual:
http://php.net/session_set_cookie_params
The Cookie in question is used to uniquely identify a surfer with PHP's
session files for that surfer.
What exactly to you think this function *DOES* if you aren't using
sessions and session files?
NOTHING!
It sets the file to be used when PHP sends the PHPSESSID Cookie which is
used for PHP's Session files.  Period.
Sorry, you completely wrong. Please, read about cookies, especialy the 
Path parameter.

Thus my point remains:
On a shared server, I don't need to resort to calling this function to
hijack your Cookie/session.  PHP can read the raw session files.  I can
write a PHP script to read the raw session files, regardless of what
directory the Cookie is set to use to store/retrieve the Cookie whose
purpose is to identify those files.
Not if php is running under suexec+cgi or safe mode.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: end of array

2005-01-22 Thread M. Sokolewicz
Raj Shekhar wrote:
M. Sokolewicz [EMAIL PROTECTED] writes:

Raj Shekhar wrote:

$n_elts = count($myarray);
for ($i=0; $i $n_elts ; $i++)
{
   if ($i = $n_elts -1)
  ^^^
Use of == required to make it work 


   {
   echo On last element;
   break;
   }
   else
   {
   echo Somwhere in the middle;
   }
}
that's an eternal loop in case you hadn't noticed (*rolls eyes*)

Oops :( not eternal loop though, only one loop 
why one?
for($i=0; $i$n;$i++) {
$i = ($n-1);
}
to me that means the following:
1. check if $i$n; true! ($i=0; $n1)
2. $i=$n-1, this means that $i$n (less by 1 in fact)
3. check if $i$n; true! ($i=$n-1; $n$i by definition)
4. $i is reset to $n-1
5-eternity. conditions are met, and var is reset
or am I missing something here? :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Classes and parents.

2005-01-22 Thread M. Sokolewicz
Jochem Maas wrote:
Dmitry wrote:
Thanks,
but I think that this code more easy.
class a {
 function say() { echo A; }
 function run() { $this-say(); }
}
class b {
 function say() { echo B; }
 function run() {
$a = new a;
$a-run();

for starters b doesn't even extend a
and secondly the b::run() method is creating an object
on each invocation - not exactly good use of OO.
besides which b::run() is creating an object of an arbitrary
class, assuming b was supposed to extend a in your example above
the you have hardcoded the parent into the subclass, thats plain wrong...
my example wasn't a specific solution to your problem but an example of 
3 ways to acomplish the goal of calling the version of a method in the 
super class. if you didn't understand something just ask.

}
}
$obj = new b;
$obj-run();
class a {
   function say() { echo A; }
   function run() { self::say(); }
}
class b {
   function say() { echo B; }
   function run() {
  parent::run();
   }
}
would work fine though, I think :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] looking for a combination contact application/social networking app

2005-01-22 Thread Bruce Douglas
hi...

i'm in need of a glorified contact type application. i want/need to be able to 
allow
users to enter their information into the system, specify what category(s) they 
belong to, be able to see others, rank others, etc...

i also would like to be able to have some form of relational/6-degrees/ryze type
of system so the users can see/find others with similar interests.. 

and of course, i'd like this to be open source!!!

anbody have any ideas, or seen anything closely resembling anything like this.. 
i'd even be willing to look at multiple apps, with the intent of putting them 
together
as a comprehensive app!!

thanks

bruce
[EMAIL PROTECTED]

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



[PHP] Loading all clases always

2005-01-22 Thread Ben Edwards (lists)
I have all my classes in a single directory.  I was thinking of
automatically loading them all at the beginning of every page.  The
logic being that the class definitions will get cached (I guess PHP uses
filesize/date/time) so the overhead would not be that great.  Also at
any given time they will all probably be needed by one of the visitors.

Ben 
-- 
Ben Edwards - Poole, UK, England
If you have a problem sending me email use this link
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

-- 
Ben Edwards - Poole, UK, England
If you have a problem sending me email use this link
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)



signature.asc
Description: This is a digitally signed message part


Re: [PHP] looking for a combination contact application/social networking app

2005-01-22 Thread trobi
Bruce Douglas napsal(a):
hi...
i'm in need of a glorified contact type application. i want/need to be able to allow
users to enter their information into the system, specify what category(s) they 
belong to, be able to see others, rank others, etc...

i also would like to be able to have some form of relational/6-degrees/ryze type
of system so the users can see/find others with similar interests.. 

and of course, i'd like this to be open source!!!
anbody have any ideas, or seen anything closely resembling anything like this.. 
i'd even be willing to look at multiple apps, with the intent of putting them together
as a comprehensive app!!

thanks
bruce
[EMAIL PROTECTED]
 

go head, and program it.
trobi
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Loading all clases always

2005-01-22 Thread Chris
You may want to look at the PHP 5 __autoload function:
http://www.php.net/oop5.autoload
I know it's not the answer to your question, but it could be just as 
good, or better, than what you were looking for.

Chris
Ben Edwards (lists) wrote:
I have all my classes in a single directory.  I was thinking of
automatically loading them all at the beginning of every page.  The
logic being that the class definitions will get cached (I guess PHP uses
filesize/date/time) so the overhead would not be that great.  Also at
any given time they will all probably be needed by one of the visitors.
Ben 
 

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


[PHP] Is this even possible?

2005-01-22 Thread Tony Di Croce
Is it even possible to connect to a postgres server (thats running on
linux) from a windows CLI php script?

I'm seeing a pg_connect() error... FATAL: no pg_hba.conf  entry for
host 192.168.1.100

Any ideas?

-- 

td

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



Re: [PHP] end of array

2005-01-22 Thread Jeffery Fernandez
Rasmus Lerdorf wrote:
Jeffery Fernandez wrote:
Hi all,
I have a foreach loop on an array and within that loop I need to find 
if the array has reached the last pointer. I have tried

if (next($row))
{
}
but that advances the pointer. Any tips on finding out if the array 
pointer has reached the last element ?

end($arr);
$last = key($arr);
foreach($arr as $key=$elem) {
   if($key !== $last) {
  ...
   }
}
That would do exactly what you asked, however, it sounds like if you 
want to do something for every item in the array except the last you 
should just remove that last item before your loop.

$last = array_pop($arr);
foreach($arr as $elem) {
   ...
}
-Rasmus
Exactly what I wanted. Thanks everyone who contributed.
cheers,
Jeffery
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Is this even possible?

2005-01-22 Thread Jason Wong
On Sunday 23 January 2005 07:20, Tony Di Croce wrote:
 Is it even possible to connect to a postgres server (thats running on
 linux) from a windows CLI php script?

Yes.

 I'm seeing a pg_connect() error... FATAL: no pg_hba.conf  entry for
 host 192.168.1.100

Exactly. So put the appropriate entry in pg_hba.conf.

 Any ideas?

Hop over to the postgresql site and consult the manual.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



[PHP] Why no type hints for built-in types?

2005-01-22 Thread Terje Slettebø
(I've posted this to the PHP newsgroups, as well, but as many here might not
read them, I post here, as well. I hope that's not considered overboard,
and if so, please let me know)

Hi.

I'm new here, and sorry if this has been discussed before; I didn't find it
searching the PHP groups. (I've also read recommendations to cross-post to
the other PHP groups, but if that is discouraged, please let me know. At the
same time, please then let me know which of the many PHP groups to post to.
:) )

In PHP5, you can provide type hints for functions, like this:

class Person {...}

function f(Person $p)
{
  ...
}

Since this is optional static typing for objects, why not make the same
capability available for all types, built-in types included?

I come from a background with generally static and strong typing (C++,
Java), and having worked with PHP a couple of years, I've quite a few times
got bitten by stupid bugs that could have been caught by static typing, such
as passing an empty string - which gets converted to 0 in an arithmetic
context, when the function was supposed to receive a number, or some such,
and no error is reported. These bugs can be hard to find.

This has been suggested in a few Q  A's at Zend, such as this one:
http://www.zend.com/expert_qa/qas.php?id=104single=1

--- Start quote ---

Will be a support for type hints of simple types, like
class Foo{
public function bar(int $var) {}
}

No, type hints of simple types will not be supported. The reason is
PHP's dynamic nature. A number posted to a script will arrive as a string
even though it's a number. In this case, PHP assumes that 10 and 10 are
the same thing. Having such type hints would not fit into this
auto-conversion of PHP.

--- End quote ---

I don't find this answer satisfactory. Yes, PHP has loose/weak typing, but
at any one time, a value or a variable has a distinct type. In the example
in the quote above, you'd have to ensure that the value you pass is of the
right type.

This would also open the door to overloading, although it seems from the
replies from Andi and Zeev in the Zend forums that neither optional static
typing, nor overloading is considered at this time, and likely not in the
future, either. :/ What I have seen of arguments against it, I haven't found
sufficiently convincing, so therefore I'd like to hear about the pros and
cons of optional static typing, and possibly overloading (however, that
should really be a separate thread). What the PHP manual calls overloading
has really nothing to do with the concept of overloading in other OO
languages, such as C++/Java.

There's a rather lively discussion about adding optional static typing in
Python (http://www.artima.com/weblogs/viewpost.jsp?thread=85551), and unless
it has already been, maybe it's time for us to consider it for PHP, as well.
The current static type checking in PHP5 is something rather half-baked,
only covering user-defined types.

Regards,

Terje

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



[PHP] Why is access and visibility mixed up in PHP?

2005-01-22 Thread Terje Slettebø
(I've posted this to the PHP newsgroups, as well, but as many here might not
read them, I post here, as well. I hope that's not considered overboard,
and if so, please let me know)

Well, as is customary when you're new to a group, you tend to post quite a
bit, :) so here's one more. Some things I've been wondering about with PHP
(5).

Today, I worked on an implementation of a finite state machine. Unlike the
pear::fsm, this one supports hierarchical states, and I intend to make it
available, as well. It exists in both PHP 4 and 5 versions, but only the
PHP5 version is relevant for this example. The base class defines some
(virtual) functions that may be overridden in a derived class, but they are
only called from the base class. My original code was as follows (I only
quote the bare minimum needed for illustration):

class fsm
{
  ...
  public function process($signal)
  {
// null_action() is called from here (unless another action function is
specified for a transition)
  }

  private function null_action($from_state,$to_state)
  {
  }
}

class my_fsm extends fsm
{
  private function null_action($from_state,$to_state)
  {
echo Transition from $from_state to $to_state;
  }
}

In C++ this would work just fine: As null_action() is called from fsm, and
it's private in fsm, this works fine. It gets overridden in my_fsm, but
being private in fsm, it can only be called there (not in my_fsm), which is
as intended. This is because access and visibility are orthogonal concepts
in C++: The access specifiers only specify who are allowed to access (as in
calling, taking the address of, etc.) a function, but it doesn't affect
overriding.

The reason for this is as follows (from The Design and Evolution of C++):
By not letting the access specifiers affect visibility (including
overriding), changing the access specifiers of functions won't affect the
program semantics.

However, this is not so for PHP...

The above won't work, or at least not work as intended: The function
null_action() will only be visible in the class it's defined, and therefore
the derived class version won't override the base class version. In order to
get it to work, the access specifiers have to be changed to protected. This
means that derived classes may also _call_ the function, something that is
not desired. This means I can't enforce this design constraint of having
this function private.

Why is it done like this?

Regards,

Terje

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



[PHP] Why no overloading in PHP5?

2005-01-22 Thread Terje Slettebø
(I've posted this to the PHP newsgroups, as well, but as many here might not
read them, I post here, as well. I hope that's not considered overboard,
and if so, please let me know)

To round off my trilogy of why's about PHP... :) If this subject have been
discussed before, I'd appreciate a pointer to it. I again haven't found it
in a search of the PHP groups.

The PHP manual mentions overloading
(http://www.php.net/manual/en/language.oop5.overloading.php), but it isn't
really overloading at all... Not in the sense it's used in other languages
supporting overloading (such as C++ and Java). As one of the
user-contributed notes on that page says, it would be more appropriate to
call it dynamic methods and properties. What overloading in PHP is
about, is to be able to do $object-name(...), and it will call the
built-in function __call() with name and an array of the parameters.

Since overloading is used in this rather confusing sense (compared to
other languages) in PHP, it may be useful with a brief recap of how it works
in C++ and Java. In these languages, overloading means that you may have
several (member or non-member) functions with the same name, as long as
their signature is different (number and type of arguments). Translated to
PHP, this could look like this:

function f($a) {...}// #1
function f($a, $b) {...} // #2
function f($a, b$, $c) {...}   // #3
function f(Person $a) {...}  // # 4

f(1);   // Calls #1
f(1,test); // Calls #2
f(1,2,3);// Calls #3
$obj=new Person();
f($obj); // Calls #4

The last call would technically also match #1, but the one with type hint
(Person) might be considered more specialised.

This issue has, like type hints for built-in types, been asked in a Zend Q 
A, such as this one: http://www.zend.com/expert_qa/qas.php?id=10single=1

--- Start quote ---

public Object child() {
return this.child;
}
public Object child(Object p_child) {
this.child = p_child;
return this.child();
}

So this is what you call function overloading? Questions: - Why is it called
function overloading? - Why won't it be supported in PHP? (important)

It is called function overloading because you have two instances of the
same function name but they differ only by the function arguments. You
expect the right one to be called according to the arguments. It won't be
supported by PHP because it doesn't fit in with its dynamically typed value
paradigm and execution methodology. However, you may reach similar affects
by using optional function arguments for example:

public Object child(Object p_child=NULL) {
if (p_child != NULL) {
this.child = p_child;
}
return this.child;
}

--- End quote ---

Again, I don't find the answer satisfactory, but perhaps someone here can
convince me?

Even if PHP has loose/weak typing, then as for type hints for built-in
types, a value or variable has a specific type at any one time. At the very
least, one might provide overloading for functions taking arguments of
user-defined types (objects), in the same way as one provide optional static
typing in the form of type hints. I.e.:

function print(Person $p) {...}
function print(Something $s) {...}

Comments?

Regards,

Terje

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



Re: [PHP] Why no type hints for built-in types?

2005-01-22 Thread Terje Slettebø
Ahem, in my posts, substitute static typing with explicit/manifest
typing (specifying the type of variables/parameters). After all, these are
checked at run-time, so a call that's not made won't be checked.

Regards,

Terje

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



[PHP] php5 --enable-soap compile error

2005-01-22 Thread Marten Lehmann
Hello,
if I'm compiling php5.0.3 with --enable-soap on a redhat enterprise 
linux 3 system I get an error almost at the end:

gcc  -Isapi/cgi/ -I/usr/src/redhat/BUILD/php-5.0.3/sapi/cgi/ 
-DPHP_ATOM_INC -I/usr/src/redhat/BUILD/php-5.0.3/include 
-I/usr/src/redhat/BUILD/php-5.0.3/main -I/usr/src/redhat/BUILD/php-5.0.3 
-I/usr/src/redhat/BUILD/php-5.0.3/Zend -I/usr/include/libxml2 
-I/usr/include/freetype2 -I/usr/include/imap -I/usr/kerberos/include 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/oniguruma 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl/mbfl 
-I/vrmd/webserver/mhash/include -I/usr/include/mysql 
-I/usr/include/pspell  -I/usr/src/redhat/BUILD/php-5.0.3/TSRM 
-I/usr/kerberos/include  -c 
/usr/src/redhat/BUILD/php-5.0.3/sapi/cgi/cgi_main.c -o 
sapi/cgi/cgi_main.o   echo  sapi/cgi/cgi_main.lo
gcc  -Isapi/cgi/ -I/usr/src/redhat/BUILD/php-5.0.3/sapi/cgi/ 
-DPHP_ATOM_INC -I/usr/src/redhat/BUILD/php-5.0.3/include 
-I/usr/src/redhat/BUILD/php-5.0.3/main -I/usr/src/redhat/BUILD/php-5.0.3 
-I/usr/src/redhat/BUILD/php-5.0.3/Zend -I/usr/include/libxml2 
-I/usr/include/freetype2 -I/usr/include/imap -I/usr/kerberos/include 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/oniguruma 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl/mbfl 
-I/vrmd/webserver/mhash/include -I/usr/include/mysql 
-I/usr/include/pspell  -I/usr/src/redhat/BUILD/php-5.0.3/TSRM 
-I/usr/kerberos/include  -c 
/usr/src/redhat/BUILD/php-5.0.3/sapi/cgi/getopt.c -o sapi/cgi/getopt.o 
 echo  sapi/cgi/getopt.lo
gcc  -Imain/ -I/usr/src/redhat/BUILD/php-5.0.3/main/ -DPHP_ATOM_INC 
-I/usr/src/redhat/BUILD/php-5.0.3/include 
-I/usr/src/redhat/BUILD/php-5.0.3/main -I/usr/src/redhat/BUILD/php-5.0.3 
-I/usr/src/redhat/BUILD/php-5.0.3/Zend -I/usr/include/libxml2 
-I/usr/include/freetype2 -I/usr/include/imap -I/usr/kerberos/include 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/oniguruma 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl/mbfl 
-I/vrmd/webserver/mhash/include -I/usr/include/mysql 
-I/usr/include/pspell  -I/usr/src/redhat/BUILD/php-5.0.3/TSRM 
-I/usr/kerberos/include  -c main/internal_functions.c -o 
main/internal_functions.o   echo  main/internal_functions.lo
/bin/sh /usr/src/redhat/BUILD/php-5.0.3/libtool --silent 
--preserve-dup-deps --mode=link gcc -export-dynamic 
-I/usr/kerberos/include  -L/usr/kerberos/lib -L/vrmd/webserver/mhash/lib 
-L/usr/lib/mysql  -R /usr/kerberos/lib -R /vrmd/webserver/mhash/lib -R 
/usr/lib/mysql ext/libxml/libxml.lo ext/openssl/openssl.lo 
ext/openssl/xp_ssl.lo ext/zlib/zlib.lo ext/zlib/zlib_fopen_wrapper.lo 
ext/bcmath/bcmath.lo ext/bcmath/libbcmath/src/add.lo 
ext/bcmath/libbcmath/src/div.lo ext/bcmath/libbcmath/src/init.lo 
ext/bcmath/libbcmath/src/neg.lo ext/bcmath/libbcmath/src/outofmem.lo 
ext/bcmath/libbcmath/src/raisemod.lo ext/bcmath/libbcmath/src/rt.lo 
ext/bcmath/libbcmath/src/sub.lo ext/bcmath/libbcmath/src/compare.lo 
ext/bcmath/libbcmath/src/divmod.lo ext/bcmath/libbcmath/src/int2num.lo 
ext/bcmath/libbcmath/src/num2long.lo ext/bcmath/libbcmath/src/output.lo 
ext/bcmath/libbcmath/src/recmul.lo ext/bcmath/libbcmath/src/sqrt.lo 
ext/bcmath/libbcmath/src/zero.lo ext/bcmath/libbcmath/src/debug.lo 
ext/bcmath/libbcmath/src/doaddsub.lo 
ext/bcmath/libbcmath/src/nearzero.lo ext/bcmath/libbcmath/src/num2str.lo 
ext/bcmath/libbcmath/src/raise.lo ext/bcmath/libbcmath/src/rmzero.lo 
ext/bcmath/libbcmath/src/str2num.lo ext/bz2/bz2.lo 
ext/calendar/calendar.lo ext/calendar/dow.lo ext/calendar/french.lo 
ext/calendar/gregor.lo ext/calendar/jewish.lo ext/calendar/julian.lo 
ext/calendar/easter.lo ext/calendar/cal_unix.lo ext/ctype/ctype.lo 
ext/curl/interface.lo ext/curl/multi.lo ext/curl/streams.lo 
ext/dba/dba.lo ext/dba/dba_cdb.lo ext/dba/dba_db2.lo ext/dba/dba_dbm.lo 
ext/dba/dba_gdbm.lo ext/dba/dba_ndbm.lo ext/dba/dba_db3.lo 
ext/dba/dba_db4.lo ext/dba/dba_flatfile.lo ext/dba/dba_inifile.lo 
ext/dba/dba_qdbm.lo ext/dba/libcdb/cdb.lo ext/dba/libcdb/cdb_make.lo 
ext/dba/libcdb/uint32.lo ext/dba/libflatfile/flatfile.lo 
ext/dba/libinifile/inifile.lo ext/dom/php_dom.lo ext/dom/attr.lo 
ext/dom/document.lo ext/dom/domerrorhandler.lo ext/dom/domstringlist.lo 
ext/dom/domexception.lo ext/dom/namelist.lo 
ext/dom/processinginstruction.lo ext/dom/cdatasection.lo 
ext/dom/documentfragment.lo ext/dom/domimplementation.lo 
ext/dom/element.lo ext/dom/node.lo ext/dom/string_extend.lo 
ext/dom/characterdata.lo ext/dom/documenttype.lo 
ext/dom/domimplementationlist.lo ext/dom/entity.lo ext/dom/nodelist.lo 
ext/dom/text.lo ext/dom/comment.lo ext/dom/domconfiguration.lo 
ext/dom/domimplementationsource.lo ext/dom/entityreference.lo 
ext/dom/notation.lo ext/dom/xpath.lo ext/dom/dom_iterators.lo 
ext/dom/typeinfo.lo ext/dom/domerror.lo ext/dom/domlocator.lo 
ext/dom/namednodemap.lo ext/dom/userdatahandler.lo ext/exif/exif.lo 

Re: [PHP] php5 --enable-soap compile error

2005-01-22 Thread Marten Lehmann
Note:
the problem seems to start a bit earlier:
gcc  -Iext/soap/ -I/usr/src/redhat/BUILD/php-5.0.3/ext/soap/ 
-DPHP_ATOM_INC -I/usr/src/redhat/BUILD/php-5.0.3/include 
-I/usr/src/redhat/BUILD/php-5.0.3/main -I/usr/src/redhat/BUILD/php-5.0.3 
-I/usr/src/redhat/BUILD/php-5.0.3/Zend -I/usr/include/libxml2 
-I/usr/include/freetype2 -I/usr/include/imap -I/usr/kerberos/include 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/oniguruma 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl/mbfl 
-I/vrmd/webserver/mhash/include -I/usr/include/mysql 
-I/usr/include/pspell  -I/usr/src/redhat/BUILD/php-5.0.3/TSRM 
-I/usr/kerberos/include  -c 
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/soap.c -o ext/soap/soap.o   
echo  ext/soap/soap.lo
gcc  -Iext/soap/ -I/usr/src/redhat/BUILD/php-5.0.3/ext/soap/ 
-DPHP_ATOM_INC -I/usr/src/redhat/BUILD/php-5.0.3/include 
-I/usr/src/redhat/BUILD/php-5.0.3/main -I/usr/src/redhat/BUILD/php-5.0.3 
-I/usr/src/redhat/BUILD/php-5.0.3/Zend -I/usr/include/libxml2 
-I/usr/include/freetype2 -I/usr/include/imap -I/usr/kerberos/include 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/oniguruma 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl 
-I/usr/src/redhat/BUILD/php-5.0.3/ext/mbstring/libmbfl/mbfl 
-I/vrmd/webserver/mhash/include -I/usr/include/mysql 
-I/usr/include/pspell  -I/usr/src/redhat/BUILD/php-5.0.3/TSRM 
-I/usr/kerberos/include  -c 
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/php_encoding.c -o 
ext/soap/php_encoding.o   echo  ext/soap/php_encoding.lo
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/php_encoding.c: In function 
`to_zval_string':
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/php_encoding.c:498: warning: 
initialization makes pointer from integer without a cast
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/php_encoding.c: In function 
`to_zval_stringr':
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/php_encoding.c:534: warning: 
initialization makes pointer from integer without a cast
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/php_encoding.c: In function 
`to_zval_stringc':
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/php_encoding.c:570: warning: 
initialization makes pointer from integer without a cast
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/php_encoding.c: In function 
`to_xml_string':
/usr/src/redhat/BUILD/php-5.0.3/ext/soap/php_encoding.c:638: warning: 
initialization makes pointer from integer without a cast

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


Re: [PHP] Why no type hints for built-in types?

2005-01-22 Thread Rasmus Lerdorf
Terje Slettebø wrote:
I don't find this answer satisfactory. Yes, PHP has loose/weak typing, but
at any one time, a value or a variable has a distinct type. In the example
in the quote above, you'd have to ensure that the value you pass is of the
right type.
Well, like it or not, that is the way it is.  PHP is first and foremost 
a web scripting language.  Browsers don't send a type along with each 
bit of information they send.  Everything comes across as a string and 
as such all the internal PHP functions do the right thing when you pass 
a string to a function that really takes a number.  We have no plans to 
break this and create an inconsistent set of functions that no longer do 
this.

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


[PHP] Geographical tendancies with RemoteHost

2005-01-22 Thread John Taylor-Johnston
With my counter, I track RemoteHost and IPAddress and save it in a mysql table. 
One of my colleagues asked me these questions (below).
I can track number of hits per month. Is there any OS code anywhere that I 
might implement to see geographical tendencies?

John

Is it possible to track this as a statistical graph that gives us average
hits per month over a longer period? This would be useful for further grant
applications. Also of course if we could track hits per rough geographical
regions (i.e. Quebec, Canada, North America, Latin America, Europe, Other).
Is this doable without too much effort?

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



[PHP] wiki as php object?

2005-01-22 Thread Kurt Yoder
Hi folks
I am creating a php site that will eventually include a wiki. The twist 
is that visitors to my site will each be able to create their own 
sections. Each section should have its own wiki, completely independent 
of all the other wikis. I could of course code up my own wiki from 
scratch, but would prefer not to have to re-invent the wheel.

I have found many wiki implementations that are full-blown 
applications. Has anyone seen a wiki implementation that is more 
integration friendly? Ideally, a wiki could be created, accessed, and 
displayed as an object so that I could completely encapsulate it within 
my own code. This would give me complete control over url's, look and 
feel, etc.

Anyone have any suggestions?
--
Kurt Yoder
http://yoderhome.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: wiki as php object?

2005-01-22 Thread Matthew Weier O'Phinney
* Kurt Yoder [EMAIL PROTECTED]:
 I am creating a php site that will eventually include a wiki. The twist 
 is that visitors to my site will each be able to create their own 
 sections. Each section should have its own wiki, completely independent 
 of all the other wikis. I could of course code up my own wiki from 
 scratch, but would prefer not to have to re-invent the wheel.

 I have found many wiki implementations that are full-blown 
 applications. Has anyone seen a wiki implementation that is more 
 integration friendly? Ideally, a wiki could be created, accessed, and 
 displayed as an object so that I could completely encapsulate it within 
 my own code. This would give me complete control over url's, look and 
 feel, etc.

PEAR's Text_Wiki class can be used to do the WikiText - HTML
translation (and vice versa); it wouldn't be difficult to write an
object around that class to handle storage and data retrieval. (I've
actually been planning on something like that for use with my
Cgiapp.class.php project -- http://freshmeat.net/projects/cgiapp).

Other than that -- the only PHP-based wikis I've seen all act as their
own application and are not encapsulation friendly.

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



[PHP] Re: Why is access and visibility mixed up in PHP?

2005-01-22 Thread Matthew Weier O'Phinney
* Terje Slettebø [EMAIL PROTECTED]:
 (I've posted this to the PHP newsgroups, as well, but as many here might not
 read them, I post here, as well. I hope that's not considered overboard,
 and if so, please let me know)

The newsgroups are simply an NNTP interface to the mailing lists -- use
one or the other; either way, it gets to the same place.

 Today, I worked on an implementation of a finite state machine. 
snip
 The base class defines some
 (virtual) functions that may be overridden in a derived class, but they are
 only called from the base class. My original code was as follows
snip:

snip -- class with private method, subclass with private method

 In C++ this would work just fine: As null_action() is called from fsm, and
 it's private in fsm, this works fine. It gets overridden in my_fsm, but
 being private in fsm, it can only be called there (not in my_fsm), which is
 as intended. This is because access and visibility are orthogonal concepts
 in C++: The access specifiers only specify who are allowed to access (as in
 calling, taking the address of, etc.) a function, but it doesn't affect
 overriding.

 The reason for this is as follows (from The Design and Evolution of C++):
 By not letting the access specifiers affect visibility (including
 overriding), changing the access specifiers of functions won't affect the
 program semantics.

 However, this is not so for PHP...

 The above won't work, or at least not work as intended: The function
 null_action() will only be visible in the class it's defined, and therefore
 the derived class version won't override the base class version. In order to
 get it to work, the access specifiers have to be changed to protected. This
 means that derived classes may also _call_ the function, something that is
 not desired. This means I can't enforce this design constraint of having
 this function private.

 Why is it done like this?

I'm not sure why the behaviour is as it is, but I do know that PHP
developers were heavily influenced by Java when writing the new PHP5
object model; I suspect your answers may lie there. 

One question I have to ask of you: why would you want the derived class
to be able to know a method exists if it will not be able to call it?
This seems to me to be... well, silly. Either the method is available to
the class or it isn't and/or the method is available to an instantiated
object or it isn't; visibility as being orthagonal to access just
doesn't make a lot of sense to me. Perhaps you could make a case as to
when this would be beneficial?

You might also want to take some of your questions to the php-dev list
-- they seem to be more related to the internals of PHP than PHP usage.

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



Re: [PHP] Loading all clases always

2005-01-22 Thread Matthew Weier O'Phinney
* Chris [EMAIL PROTECTED]:
 You may want to look at the PHP 5 __autoload function:

 http://www.php.net/oop5.autoload

These are semi-available in PHP4 as well -- look up 'overload' in the
function reference.

 I know it's not the answer to your question, but it could be just as 
 good, or better, than what you were looking for.

The OP might also want to look up the INI variable 'auto_prepend_file'
if they really *do* want to load all classes on each page call -- this
would eliminate the need to modify all scripts in the web tree. It could
also be used with the overload/__autoload functions (PHP4 or PHP5) --
the auto_prepend_file could contain the __autoload function definition.

 Ben Edwards (lists) wrote:
  I have all my classes in a single directory.  I was thinking of
  automatically loading them all at the beginning of every page.  The
  logic being that the class definitions will get cached (I guess PHP uses
  filesize/date/time) so the overhead would not be that great.  Also at
  any given time they will all probably be needed by one of the visitors.

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



[PHP] Re: Why no type hints for built-in types?

2005-01-22 Thread Matthew Weier O'Phinney
* Terje Slettebø [EMAIL PROTECTED]:
 In PHP5, you can provide type hints for functions, like this:

 class Person {...}

 function f(Person $p)
 {
   ...
 }

 Since this is optional static typing for objects, why not make the same
 capability available for all types, built-in types included?

 I come from a background with generally static and strong typing (C++,
 Java), and having worked with PHP a couple of years, I've quite a few times
 got bitten by stupid bugs that could have been caught by static typing, such
 as passing an empty string - which gets converted to 0 in an arithmetic
 context, when the function was supposed to receive a number, or some such,
 and no error is reported. These bugs can be hard to find.

This is where the === and !== comparison operators can come in handy, as
they compare not only the values but the types. I often need to do this
when checking for zeroes.

 This has been suggested in a few Q  A's at Zend, such as this one:
 http://www.zend.com/expert_qa/qas.php?id=104single=1

 --- Start quote ---

 Will be a support for type hints of simple types, like
 class Foo{
 public function bar(int $var) {}
 }

 No, type hints of simple types will not be supported. The reason is
 PHP's dynamic nature. A number posted to a script will arrive as a string
 even though it's a number. In this case, PHP assumes that 10 and 10 are
 the same thing. Having such type hints would not fit into this
 auto-conversion of PHP.

 --- End quote ---

 I don't find this answer satisfactory. Yes, PHP has loose/weak typing, but
 at any one time, a value or a variable has a distinct type. In the example
 in the quote above, you'd have to ensure that the value you pass is of the
 right type.

I can recognize that this answer would not be satisfactory for someone
with a background in traditional application architecture. However, PHP
has been developed from the beginning as a programming language for the
web. Since the nature of web requests is to transfer all values as
strings, PHP needs to be able to compare items of different types -- '0'
needs to evaluate to the same thing as 0. This may not be optimal for
many applications, but for most web applications to which PHP is
applied, it is considered a *feature*.

 This would also open the door to overloading, although it seems from the
 replies from Andi and Zeev in the Zend forums that neither optional static
 typing, nor overloading is considered at this time, and likely not in the
 future, either. :/ What I have seen of arguments against it, I haven't found
 sufficiently convincing, so therefore I'd like to hear about the pros and
 cons of optional static typing, and possibly overloading (however, that
 should really be a separate thread). What the PHP manual calls overloading
 has really nothing to do with the concept of overloading in other OO
 languages, such as C++/Java.

PHP already supports overloading as you're accustomed to it -- the
syntax is different, and PHP refers to the practice as variable-lentgh
argument lists. You use func_num_args(), func_get_args(), and
func_get_arg() to accomplish it:

function someOverloadedFun()
{
$numargs = func_num_args();
$args= func_get_args();
if (0 == $numargs) {
return ERROR!;
}
if (1 == $numargs) {
if (is_string($args[0])) {
return Received string: $args[0];
} elseif (is_object($args[0])) {
return Received object!;
}
} elseif ((2 == $numargs)) {
return Received arg0 == $args[0] and arg1 == $args[1];
}
// etc.
}

Yes, this is more cumbersome than providing hints -- but typically, if I
design properly, I'm checking types within already, and I've already
determined a way to limit what is passed to the function/method. One
technique I use is to pass a single associate array to a function or
method, and grab my arguments from that. 

 There's a rather lively discussion about adding optional static typing in
 Python (http://www.artima.com/weblogs/viewpost.jsp?thread=85551), and unless
 it has already been, maybe it's time for us to consider it for PHP, as well.
 The current static type checking in PHP5 is something rather half-baked,
 only covering user-defined types.

I can definitely see a use for this -- but, again, PHP has been designed
with loose typing as a *feature*. While type hinting may be a nice
additional feature, I have my doubts as to the necessity or overhead it
would incur.

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



[PHP] Re: Procedural to OOP

2005-01-22 Thread Matthew Weier O'Phinney
* Mike Smith [EMAIL PROTECTED]:
 I am rewriting a project, and have decided to use/learn OOP. I am
 using ADODB to connect to a MS SQL 2000 box. This code works, but I'd
 like to know if I'm following good form or if I'm totally missing the
 boat. I'd also like to include things like the
 dbhost/username/password, etc in a seperate config file would I...

 class foo{

 function bar(){
 include('my_config_file_here.php');// sets $dbhost etc...

 var $db_host = $dbhost;
 ...
 }
 }

 ...or is there another way.

I do the same thing... but only for areas that I consider static.
Otherwise, I pass the DSN in as a parameter to the object constructor --
and even then, I'm having it defined from a function that's in a file
outside my document root:

In Foo.class.php:

require_once 'DB.php';
class foo 
{
function foo($dsn)
{
// I use PEAR, so this is how I connect to a DB:
$db = DB::connect($dsn);
$this-db = $db;
}
}

In instance script:

require_once 'Foo.class.php';
require_once 'connection.php'; // this file is in the include path,
// but not in the web tree

$foo = new Foo(connectionFunc());

 Here is my class and my index.php which will present it. I looked at
 Smarty, but I think my head would explode trying to link
 ADODB-OOP-SMARTY. 

It's actually not difficult at all to connect ADODB/PEAR::DB to Smarty,
believe it or not. You pass resultsets directly to Smarty, and then use
Smarty's foreach or section constructs to loop over them. Once you do
that, I think you'll find your code becomes cleaner, and you have less
disconnect as you work in PHP (I often had disconnect when intermingling
HTML and PHP from trying to switch back and forth between the languages;
moving to a templating system was a huge productivity boost, as when you
work in a template, you use HTML; when you work in a script/class, you
use PHP).

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



Re: [PHP] Extending a Class

2005-01-22 Thread Matthew Weier O'Phinney
* Phillip S. Baker [EMAIL PROTECTED]:
 Thank you,

 This makes allot of sense.
 However one last question about this.

 If I access the overrided function from the child class do I access it by.

 $instanceofchildclass-parent::someMethod();

 OR would I still simply just call it

 $instanceofchildclass-someMethod();

 And it would get to use the overrided function in the child class??

The child class (assuming it has overridden a method) would access the
original method in the parent with:

parent::someMethod();

If the child class wishes to access the method it has overridden (i.e.,
it wants to access its own method, not the parent's), it uses:

$this-someMethod();

The object *instance* only gets to access the overridden method (assuming
it's an instance of the child class):

$instance-someMethod();

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



[PHP] Session errors when uploaded to host

2005-01-22 Thread Tim Burgan
Hello,
I've developed my site, and tested on a web host (Apache, PHP 4.3.9).
Now I've uploaded to a different host (IIS, PHP 4.3.1) where I want to 
keep it, and I get session error messages like:

Warning: session_start() [function.session-start 
http://www.php.net/function.session-start]: 
open(/tmp\sess_30f6794de4b0d80b91035c6c01aae52d, O_RDWR) failed: No such 
file or directory (2) in E:\W3Sites\ywamsa\www\timburgan\index.php on line 9

Warning: session_start() [function.session-start 
http://www.php.net/function.session-start]: Cannot send session cookie 
- headers already sent by (output started at 
E:\W3Sites\ywamsa\www\timburgan\index.php:9) in 
E:\W3Sites\ywamsa\www\timburgan\index.php on line 9

My code on line 9 is: This is the first line of my code
session_start();
My code on line 12 is: This is the second line of my code
header(Cache-control: private);
Is there any solution to this?
Tim

PS. I looked up session_start() in the PHP manual, and found this 
comment that may offer a solution that I've pasted below. Will this 
work? Are my problems a bug with PHP and IIS?

[START QUOTE]
*tech at insights dot net dot au*
17-Oct-2004 04:28
|I am sure anybody that is trying to use IIS and PHP is throughly 
annoyed with the session_start() bug that recreates a new session every 
time it is accessed.

The problem is the session_id isn't passed before the session_start() so 
it creates a new session. So a simple sollution is:

$id = 473483478383834;
session_id($id);
session_start();
Another way that is a bit more dynamic using a Cookie to hold the 
session_id:

if (isset($SessID)){ session_id($SessID); }
session_start();
header(Cache-control: private); // IE 6 Fix.
setcookie(SessID, session_id(), time() + 3600); 

There are probably much better ways of doing this but for use with my 
offline Win/IIS setup it seems to be fine.

[END QUOTE]
|
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] library manger ..

2005-01-22 Thread gowthaman ramasamy

Hi list,
can any one suggest a good PHP/mysql based library manager to manage
books,magazines, documents, cds etc . 
I tried libman .. but i am having problem with that .
many thanks in advance ...
with love
gowtham

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