php-general Digest 24 Oct 2005 02:34:54 -0000 Issue 3754
Topics (messages 224515 through 224529):
Re: Memory Leak?
224515 by: cron.odi.com.br
Re: Ugh, w32 anything is making me want to drink!
224516 by: Rick Emery
Re: Abstract Classes?
224517 by: Colin Shreffler
224518 by: Alan Lord
224519 by: GamblerZG
connect to MySql
224520 by: hassan mahdi
224521 by: Larry E. Ullman
224525 by: Jasper Bryant-Greene
A better way to do this
224522 by: Ross
224523 by: Jasper Bryant-Greene
Re: Email Validation built-in? RFC
224524 by: Robin Vickery
Re: Forcing auto_prepend_file to work regardless of what document was accessed
224526 by: Dan Trainor
error reporting php-5.0.4-10.4 on FC4
224527 by: Bob Hartung
224528 by: Jasper Bryant-Greene
[suspicious - maybe spam] ¾µäº«¹úÍ·ÊÎÈ«ÐÂÉÏÊÐ
224529 by: ÒÚѸµç×Ó´«µ¥
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
I think the php GC only kicks in at the end of a script some calls to
mysql_free_result might help
Angelo
----- Original Message -----
From: "Richard Lynch" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Saturday, October 22, 2005 11:40 PM
Subject: Re: [PHP] Memory Leak?
On Sat, October 22, 2005 9:24 pm, [EMAIL PROTECTED] wrote:
Sucks that you don't have more control over the incoming data.
Just for the record, for when the source of this data reads this thread.
I am ECSTATIC to have this data, period.
:-)
I know we'll work out a viable solution in time, even if replication
is not in the cards.
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Jasper Bryant-Greene wrote:
On Fri, 2005-10-21 at 15:43 -0500, Jay Blanchard wrote:
[snip]
I haven't used Windows for a while, but Start->Search->Files & folders
(or something like that) and enter php.ini. Delete all results except
the one that you've been editing, and then move the one you've been
editing around the following folder until you find the one in which it
works:
c:\php
c:\windows
c:\windows\system32
c:\
Horrible, isn't it?
[/snip]
Horrible indeed. I got no joy from this. It didn't work.
When you say didn't work... do you mean you didn't find any other
php.ini files?
There's one other thing I can think of. It's possible to set things like
the location of the php.ini file and also php configuration directives
through Apache's configuration.
Now I know you're using IIS, but is there a similar thing available
through IIS's configuration? (I wouldn't know, I don't practise the dark
arts...)
You can tell Windows where to find the php.ini file by setting the PHPRC
evironment variable. But, if you've already placed *your* php.ini file
in the location indicated by phpinfo(), then I'm not sure why it
wouldn't be read, unless:
1. From the manual: "*Note: * If you're using NTFS on Windows NT, 2000,
XP or 2003, make sure that the user running the web server has read
permissions to your php.ini (e.g. make it readable by Everyone)."
2. IIS hadn't been restarted (to re-read the new php.ini).
Other than that, not sure. Sorry.
Rick
--- End Message ---
--- Begin Message ---
One reason would be that you might not know the details of a derived class's
implementation details at design time.
For instance I could have an abstract class such as this:
Class MyTestClass
{
function doSomething()
{
doSomethingElse();
}
abstract function doSomethingElse() ;
}
As you can see I have an abstract function with no details. I know that
when the doSomething() function is called it must call the doSomethingElse
Function, but at the time that I define MyTestClass I don't know what that
is exactly.
Now say another developer needs to derive a class from MyTestClass. Because
the base class is abstract they must define an emplementation for the
doSomethingElse class such as:
Class MyDerivedClass extends MyTestClass
{
function doSomethingElse()
{
// here the developer must specify the specifics of what this method
does
}
}
Now in our business logic if we do the following:
$myClass = new MyDerivedClass();
$myClass->doSomething();
The code will actually execute the doSomethingElse() implementation that
has been defined in MyDerivedClass.
This can be extremely useful in developing frameworks that you want other
developers to extend on their own and also in business systems where you
might need to maintain a system by adding new classes/implementations over
time. Certain patterns also make heavy uses of interfaces and abstract
classes.
Perhaps a real-world example would make more sense. Does this help? If
not, let me know and I'll come up with a similar/real-world example.
Colin
On 10/23/05 4:40 AM, "Alan Lord" <[EMAIL PROTECTED]> wrote:
> Thanks Jasper,
>
> That makes sense.
>
> But what benefit is there is having it as an explicitly "abstract"
> class? Why can't it just be a "normal" class definition which you
> inherit from?
>
> Sorry to be so dense....
>
> Al
>
>> -----Original Message-----
>> From: Jasper Bryant-Greene [mailto:[EMAIL PROTECTED]
>> Sent: 23 October 2005 09:19
>> To: Alan Lord
>> Cc: [email protected]
>> Subject: Re: [PHP] Abstract Classes?
>>
>> On Sun, 2005-10-23 at 08:54 +0100, Alan Lord wrote:
>>> Hi All,
>>>
>>> I have started reading a couple of books about PHP 5 and
>> whilst most
>>> of it is comprehensible even to me :-), I fail to
>> understand WHY there
>>> is such a thing as an abstract class or method?
>>>
>>> I think I understand what it is: A class that can't itself be
>>> instantiated, only inherited from, or a method that
>> describes itself
>>> only in terms of what properties it accepts but no implementation
>>> detail.
>>>
>>> But could someone explain why I would want to use this? I'm
>> sure it is
>>> very useful but I can't quite see the benefit...
>>
>> Hi Alan
>>
>> Here's an example from an application framework I've been working on.
>>
>> It has classes to represent the different HTTP response statuses (like
>> 301 Moved Permanently, 304 Not Modified etc.) with required
>> and forbidden headers for each and different characteristics
>> (like no request-body allowed etc).
>>
>> I have an Abstract class called HTTP_Response, from which
>> HTTP_Response_Moved_Permanently, HTTP_Response_Not_Modified,
>> and many others all inherit.
>>
>> The reason HTTP_Response is abstract is because there's no
>> such thing as an HTTP_Response on its own. It has to be a
>> specific type of HTTP Response, that is a 301 Moved
>> Permanently or a 304 Not Modified.
>>
>> Does that help?
>>
>> --
>> Jasper Bryant-Greene
>> General Manager
>> Album Limited
>>
>> e: [EMAIL PROTECTED]
>> w: http://www.album.co.nz/
>> p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
>> a: PO Box 579, Christchurch 8015, New Zealand
>>
>>
Thank you,
Colin Shreffler
Principal
303.349.9010 - cell
[EMAIL PROTECTED]
Warp 9 Software, LLC.
6791 Halifax Avenue
Castle Rock, CO 80104
Confidentiality Notice: The information in this e-mail may be confidential
and/or privileged. This e-mail is intended to be reviewed by only the
individual or organization named in the e-mail address. If you are not the
intended recipient, you are hereby notified that any review, dissemination
or copying of this e-mail and attachments, if any, or the information
contained herein, is strictly prohibited.
--- End Message ---
--- Begin Message ---
Thanks,
That's starting to make some sence now!
Al
> -----Original Message-----
> From: Colin Shreffler [mailto:[EMAIL PROTECTED]
> Sent: 23 October 2005 17:03
> To: Alan Lord; 'Jasper Bryant-Greene'
> Cc: [email protected]
> Subject: Re: [PHP] Abstract Classes?
>
> One reason would be that you might not know the details of a
> derived class's implementation details at design time.
>
> For instance I could have an abstract class such as this:
>
> Class MyTestClass
> {
> function doSomething()
> {
> doSomethingElse();
> }
>
> abstract function doSomethingElse() ; }
>
> As you can see I have an abstract function with no details.
> I know that when the doSomething() function is called it must
> call the doSomethingElse Function, but at the time that I
> define MyTestClass I don't know what that is exactly.
>
> Now say another developer needs to derive a class from
> MyTestClass. Because the base class is abstract they must
> define an emplementation for the doSomethingElse class such as:
>
> Class MyDerivedClass extends MyTestClass {
> function doSomethingElse()
> {
> // here the developer must specify the specifics of
> what this method does
> }
> }
>
> Now in our business logic if we do the following:
>
> $myClass = new MyDerivedClass();
> $myClass->doSomething();
>
> The code will actually execute the doSomethingElse()
> implementation that has been defined in MyDerivedClass.
>
> This can be extremely useful in developing frameworks that
> you want other developers to extend on their own and also in
> business systems where you might need to maintain a system by
> adding new classes/implementations over time. Certain
> patterns also make heavy uses of interfaces and abstract classes.
>
> Perhaps a real-world example would make more sense. Does
> this help? If not, let me know and I'll come up with a
> similar/real-world example.
>
> Colin
>
> On 10/23/05 4:40 AM, "Alan Lord" <[EMAIL PROTECTED]> wrote:
>
> > Thanks Jasper,
> >
> > That makes sense.
> >
> > But what benefit is there is having it as an explicitly "abstract"
> > class? Why can't it just be a "normal" class definition which you
> > inherit from?
> >
> > Sorry to be so dense....
> >
> > Al
> >
> >> -----Original Message-----
> >> From: Jasper Bryant-Greene [mailto:[EMAIL PROTECTED]
> >> Sent: 23 October 2005 09:19
> >> To: Alan Lord
> >> Cc: [email protected]
> >> Subject: Re: [PHP] Abstract Classes?
> >>
> >> On Sun, 2005-10-23 at 08:54 +0100, Alan Lord wrote:
> >>> Hi All,
> >>>
> >>> I have started reading a couple of books about PHP 5 and
> >> whilst most
> >>> of it is comprehensible even to me :-), I fail to
> >> understand WHY there
> >>> is such a thing as an abstract class or method?
> >>>
> >>> I think I understand what it is: A class that can't itself be
> >>> instantiated, only inherited from, or a method that
> >> describes itself
> >>> only in terms of what properties it accepts but no implementation
> >>> detail.
> >>>
> >>> But could someone explain why I would want to use this? I'm
> >> sure it is
> >>> very useful but I can't quite see the benefit...
> >>
> >> Hi Alan
> >>
> >> Here's an example from an application framework I've been
> working on.
> >>
> >> It has classes to represent the different HTTP response statuses
> >> (like
> >> 301 Moved Permanently, 304 Not Modified etc.) with required and
> >> forbidden headers for each and different characteristics (like no
> >> request-body allowed etc).
> >>
> >> I have an Abstract class called HTTP_Response, from which
> >> HTTP_Response_Moved_Permanently,
> HTTP_Response_Not_Modified, and many
> >> others all inherit.
> >>
> >> The reason HTTP_Response is abstract is because there's no
> such thing
> >> as an HTTP_Response on its own. It has to be a specific
> type of HTTP
> >> Response, that is a 301 Moved Permanently or a 304 Not Modified.
> >>
> >> Does that help?
> >>
> >> --
> >> Jasper Bryant-Greene
> >> General Manager
> >> Album Limited
> >>
> >> e: [EMAIL PROTECTED]
> >> w: http://www.album.co.nz/
> >> p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
> >> a: PO Box 579, Christchurch 8015, New Zealand
> >>
> >>
>
>
> Thank you,
> Colin Shreffler
> Principal
> 303.349.9010 - cell
> [EMAIL PROTECTED]
>
> Warp 9 Software, LLC.
> 6791 Halifax Avenue
> Castle Rock, CO 80104
>
> Confidentiality Notice: The information in this e-mail may be
> confidential and/or privileged. This e-mail is intended to be
> reviewed by only the individual or organization named in the
> e-mail address. If you are not the intended recipient, you
> are hereby notified that any review, dissemination or copying
> of this e-mail and attachments, if any, or the information
> contained herein, is strictly prohibited.
>
>
>
>
>
>
--- End Message ---
--- Begin Message ---
Alan Lord wrote:
But what benefit is there is having it as an explicitly "abstract"
class? Why can't it just be a "normal" class definition which you
inherit from?
The idea is that a high-level language should prohobit you from doing
things that do not make sence. Why they implemented it in PHP? Because
it's there in Java, I guess.
--- End Message ---
--- Begin Message ---
Dear Sir
I have windows XP sevice pack 1 and 2, PHPv5.0.5, Mysql v1. I am working in web
design. I am unable to connect to the mysql server. Althought my php files
running fine and my mysql server is also running fine.
i) i had changed the php.ini-dist file to php.ini.
ii)i uncommented the extensions of php_mysql.dll in php.ini file
iii)i set the
extensions_dir to extension_dir = "D:\PHP\php-5.0.3\ext\" in php.ini file
iv)i had copied the libmysql.dll in windows\system32 and windows\system i wrote
the following code:
<?php $dbhost = "localhost";
$dbusername = "root";
$dbpassword = "admin";
$dbname = "test";
$connect = @mysql_connect ( $dbhost,$dbusername,$dbpassword )
or die ("Could not connect ".mysql_error());
mysql_select_db($dbname,$connect) or die("Could not select
database".mysql_error()); ?>
but after all these i am still getting the error Fatal error: Call to
undefined function mysql_connect() in D:\PHP\teknohub\new.php on line 14 please
help me to solve this problem out.
Dr. Hassan
--------------------------------------------
Hassan Al-Mahdi
Associate Lecture Of Computer Science
Department of Mathematics and Science
Faculty of Petroleum and Mining Engineering
Suez Canal University,
Suez, Egypt
Phone: not available now
Email: [EMAIL PROTECTED]
Website: http://hassan460.tripod.com
---------------------------------
Yahoo! FareChase - Search multiple travel sites in one click.
--- End Message ---
--- Begin Message ---
I have windows XP sevice pack 1 and 2, PHPv5.0.5, Mysql v1. I am
working in web design. I am unable to connect to the mysql server.
Althought my php files running fine and my mysql server is also
running fine.
i) i had changed the php.ini-dist file to php.ini.
ii)i uncommented the extensions of php_mysql.dll in php.ini file
iii)i set the extensions_dir to extension_dir = "D:\PHP\php-5.0.3
\ext\" in php.ini file
iv)i had copied the libmysql.dll in windows\system32 and windows
\system
but after all these i am still getting the error Fatal error: Call
to undefined function mysql_connect() in D:\PHP\teknohub\new.php on
line 14 please help me to solve this problem out.
You haven't successfully enabled MySQL support. You can confirm this
by running a phpinfo() script. Did you restart Apache after editing
the php.ini file? And are you certain you are editing the _right_
php.ini file (the one indicated when you run phpinfo())?
Larry
--- End Message ---
--- Begin Message ---
On Fri, 2005-10-21 at 12:06 -0700, hassan mahdi wrote:
> I have windows XP sevice pack 1 and 2, PHPv5.0.5, Mysql v1. I am working in
> web design. I am unable to connect to the mysql server. Althought my php
> files running fine and my mysql server is also running fine.
MySQL 1? Really? That's a *very* old version, you should really
upgrade :)
> i) i had changed the php.ini-dist file to php.ini.
>
> ii)i uncommented the extensions of php_mysql.dll in php.ini file
>
> iii)i set the
>
> extensions_dir to extension_dir = "D:\PHP\php-5.0.3\ext\" in php.ini file
If you're running PHP 5.0.5 then why is the directory called php-5.0.3?
> iv)i had copied the libmysql.dll in windows\system32 and windows\system i
> wrote the following code:
>
> [snip]
>
> but after all these i am still getting the error Fatal error: Call to
> undefined function mysql_connect() in D:\PHP\teknohub\new.php on line 14
> please help me to solve this problem out.
Confirm that:
a) there exists a file php_mysql.dll in the directory D:\PHP\php-5.0.3
\ext
b) the php.ini file that you have been editing matches the one displayed
if you create a file containing <?php phpinfo(); ?> and view it with
your web browser
--
Jasper Bryant-Greene
General Manager
Album Limited
e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand
--- End Message ---
--- Begin Message ---
I want the selct table to retain it's value on submit. The way I have done
it works but is a bit rubbish and was wondering if there is a more efficient
way. I just make the variable equal to "selected" when the form is submitted
<select name="table_name" id="table_name">
<option value="1" <?=$one; ?>>Please Select</option>
<option value="news" <?=$two; ?>News</option>
<option value="events" <?=$three; ?>Events</option>
<option value="publications" <?=$four; ?>Publications</option>
</select>
Thanks,
R.
--- End Message ---
--- Begin Message ---
On Sun, 2005-10-23 at 20:23 +0100, Ross wrote:
> I want the selct table to retain it's value on submit. The way I have done
> it works but is a bit rubbish and was wondering if there is a more efficient
> way. I just make the variable equal to "selected" when the form is submitted
>
> <select name="table_name" id="table_name">
> <option value="1" <?=$one; ?>>Please Select</option>
> <option value="news" <?=$two; ?>News</option>
> <option value="events" <?=$three; ?>Events</option>
> <option value="publications" <?=$four; ?>Publications</option>
> </select>
<?php
$selectValues = array(
'1' => 'Please select',
'news' => 'News',
'events' => 'Events',
'publications' => 'Publications'
);
print( '<select name="table_name" id="table_name">' );
foreach( $selectValues as $value => $option ) {
print( '<option value="' . htmlspecialchars( $value ) . '"' );
if( $_POST['table_name'] == $value ) {
print( ' selected' );
}
print( '>' . htmlspecialchars( $option ) . '</option>' );
}
print( '</select>' );
?>
If you're using XHTML, replace ' selected' with ' selected="selected"'
--
Jasper Bryant-Greene
General Manager
Album Limited
e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand
--- End Message ---
--- Begin Message ---
On 10/23/05, Manuel Lemos <[EMAIL PROTECTED]> wrote:
> Hello,
>
>
> on 10/22/2005 12:58 AM Richard Lynch said the following:
> > Checking MX records is not reliable at all.
>
> I agree that it is less useful today, but it still help catches many
> domain name typos.
>
>
> > ... would it not make sense for there to be a BUILT-IN PHP function of
> > a TRUE email syntactic validation?
>
> I don't see that being much better than passing a good regular
> expression to preg_match.
1. Technically you can't write a regular expression that matches
*all* valid email addresses as part of the address specification is
recursive.
ccontent = ctext / quoted-pair / comment
comment = "(" *([FWS] ccontent) [FWS] ")"
Admittedly 99.99% of people don't even know you *can* comment email
addresses so it's not a huge problem...
2. Very few people seem to be capable of recognising a *good* regular
expression, let alone writing one. It seems clear that validating an
address is a task that many people want to do, but few can do
properly. I'd say that's a good reason for making it a built-in
function.
>
> For many years I use this regular expression in popular email validation
> and forms generation and validation classes.
>
>
> Rather than accepting only valid characters, it rejects all invalid
> characters as specified in the RFC.
>
> ^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}$
>
I'm sorry, but this regular expression rejects many perfectly valid
ASCII characters. It seems to take into account only dot-atoms, not
quoted-strings. It also rejects valid addresses using domain-literals.
-robin
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Sat, October 22, 2005 11:42 pm, Dan Trainor wrote:
This would be a great solution, and I'm sure my concern is something
that's been discussed many times on this list - I'm worried about the
performance hit that the machine would take, if/when parsing a large
number of files, in this manner.
For small sites, I have no problem adding .html, .htm and friends to
PHP's own AddType. But I'm not so sure for larger sites.
I'll browse the archive for info and data, and weigh my options.
Last benchmarks I saw clocked in at 5 to 10% loss to run all .htm and
html files through PHP.
That was awhile ago, though.
Test on a dev server with apache benchmark (ab) before and after and see.
PHP doesn't really *DO* much until it hits '<?php' if you think about it.
It just reads the file, uses something like strtok() to search for
'<?php' and spits it back out.
Richard -
Excellent; I'll be looking into that more.
Thanks
-dant
--- End Message ---
--- Begin Message ---
Hi all,
Slowly I'm progressing.
Now how to turn error reporting on for a test apache server.
I have made the following changes to /etc/php.ini:
error_reporting = E_ALL
display_errors = On
error_log = /var/log/php_errors
On errors I still have no in browser display nor is anything written
to the log file.
Any suggestions?
TIA
Bob
--- End Message ---
--- Begin Message ---
On Sun, 2005-10-23 at 17:31 -0400, Bob Hartung wrote:
> Hi all,
> Slowly I'm progressing.
> Now how to turn error reporting on for a test apache server.
>
> I have made the following changes to /etc/php.ini:
>
> error_reporting = E_ALL
> display_errors = On
> error_log = /var/log/php_errors
>
> On errors I still have no in browser display nor is anything written
> to the log file.
Make a file containing just the following line and view it in your
browser:
<?php phpinfo(); ?>
See if the path to php.ini shown in that file is /etc/php.ini. If it
isn't, then you're editing the wrong php.ini.
Also, make sure you're not overriding those values in a .htaccess file
or in a script.
What kind of errors are happening that aren't being displayed? For
example in an output buffering handler, an error could just cause your
script to output nothing.
--
Jasper Bryant-Greene
General Manager
Album Limited
e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand
--- End Message ---
--- Begin Message ---
一人是老头子,一部白胡须直垂至胸,但面皮红润泛光,没半点皱纹。另一个是四十来岁的中年人,矮矮胖胖,是个秃子,后脑拖着条小辫子,前脑如剥壳鸡蛋。
韦小宝道:“王爷不可生气。你老人家望安。千里为官只为财,我倘若去向皇上胡说八道,皇上就有什么赏赐,总也不及你老人家年年送礼打赏,岁岁发饷出粮。咱哥儿俩做笔生意,我回京之后,只把你赞得忠心耿耿、天下无双。我又一心一意,保护世子周全。逢年过节,你就送点什么金子银子来赐给小将。你说如何?”说着和吴三桂并肩而行。
--- End Message ---