php-general Digest 1 Jun 2009 15:00:34 -0000 Issue 6153
Topics (messages 293404 through 293426):
Re: Directing form to different handlers?
293404 by: Robert Cummings
Re: spawning a process that uses pipes - doesn't terminate when webpage
download is canceled
293405 by: Robert Cummings
293406 by: bruce
293410 by: flint
293417 by: Robert Cummings
293419 by: Robert Cummings
293425 by: bruce
293426 by: Robert Cummings
Re: PHP vs ASP.NET
293407 by: Manuel Lemos
293422 by: Andrew Ballard
293424 by: Dee Ayy
Jacob's Calendar
293408 by: Jacob Kutty
293420 by: Daniel Brown
mysql connections
293409 by: Grega Leskovsek
Anyone know whats the best way to learn PHP
293411 by: Muhammad Hassan Samee
293412 by: Patrick
293413 by: Michael A. Peters
293414 by: Nathan Rixham
293416 by: Peter van der Does
293418 by: Tom Worster
Instantiate SOAP Request Objects
293415 by: Samuel Vogel
Comparing data - big file
293421 by: ×× ××× ×× ××
Re: Autoloading with namespaces in 5.3.0
293423 by: Nathan Nobbe
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 ---
On Mon, 2009-06-01 at 12:53 +1000, Angus Mann wrote:
> Hi all. I realize this is more an HTML question than PHP but I'm sure someone
> here can help.
>
> I have several forms with lots (dozens) of text inputs. If the user presses
> the "Update" button I want the form handled by "update.php" but if they press
> "Delete" it needs to be handled by "delete.php" or "add.php" and so-on
> depending on the button they press.
>
> But when establishing the form I can only have <form method="POST"
> action="delete.php"> or "add.php" or whatever.
>
> Is there a way to direct the content of the form do a different handler
> depending on the button?
>
> I know I can use javascript to direct to a constructed URL and append
> ?name=smith&address=hishouse&telephone=28376.....and so on but this is not
> practical when there are dozens of entries....the URL becomes massive. I
> prefer to use "POST" and then use PHP to extract the POST array.
>
> Any ideas?
Yes, have the form submit to the URL that presented the form. Have THAT
PHP script determine which button was clicked. Then delegate to the
appropriate handler function.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
On Sun, 2009-05-31 at 08:52 -0500, flint wrote:
> sent this before, don't know if it went through... someone please reply if
> it went, even if they don't know answer?...
>
> so here's the scenario..
>
> I have a site that uses php with a database to offer sound files to
> users using streaming methods.
>
> the request page has options, allowing the user to modify the sound
> file in various ways, before having it sent to them
>
> Here's the problem:
>
> The method i'm using to feed the data to the user is to run the source
> file through various piped commands, with the resulting audio being
> dumped to stdout, and then using passthru in php to get that data to
> the enduser.
>
> here's an example, for serving an MP3 with its pitch/speed changed by sox:
>
> passthru("lame --quiet --decode \"" . $in_file . "\" - | " .
> "sox -V -S -t wav - -t wav - speed " . $speed_factor . " | " .
> "lame --quiet " . $lame_params . " - -");
>
> This works just fine, except the problem is if the end user aborts the
> transfer (e.g. stops playback in the media player, cancels download of
> the mp3, whatever) then it leaves behind both the sox process and the
> decoder LAMe process along with the sh that's running them. the only
> process that exits is the final encoding lame process. If the sound
> file runs to completion, everythign exits properly.
>
> But this obviously means enough "cancelling" of downloads means the
> server ends up with a huge batch of stuck processes! And I even tried
> simply killing the 'host' sh process, and the lame and sox processes
> remain anyway. The only way I've been able to deal with this is
> manually killing the lame and sox processes directly.
>
> is there any way I can make this work, such so that if the user
> cancels the transfer, all relavent processes are killed rather than
> just the single process that's feeding output into php?
Use something else to pass the data back to the user... popen() comes to
mind or proc_open(). Then disable auto abort on user disconnect via
ignore_user_abort(). Then after sending periodic data chunks, check the
user connection status via connection_aborted(). If your script finds
that the user has aborted, then kill all the processes in the pipeline
from the PHP script before finally aborting the PHP script itself.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
hi robert.,,
now you've got me curious..
you state...
-Use something else to pass the data back to the user... popen() comes to
-mind or proc_open(). Then disable auto abort on user disconnect via
-ignore_user_abort(). Then after sending periodic data chunks, check the
-user connection status via connection_aborted(). If your script finds
-that the user has aborted, then kill all the processes in the pipeline
-from the PHP script before finally aborting the PHP script itself.
but if the user is using a browser session... which has a web server
connection... are you siggesting that the server app spawns off a child
process via the popen, and that the child somehow connects to the existing
browser session??
walk through the psuedo logic/flow of this if you don't mind.. i must be
missing something..
thanks
-----Original Message-----
From: Robert Cummings [mailto:[email protected]]
Sent: Sunday, May 31, 2009 8:16 PM
To: flint
Cc: PHP-General List
Subject: Re: [PHP] spawning a process that uses pipes - doesn't
terminatewhen webpage download is canceled
On Sun, 2009-05-31 at 08:52 -0500, flint wrote:
> sent this before, don't know if it went through... someone please reply if
> it went, even if they don't know answer?...
>
> so here's the scenario..
>
> I have a site that uses php with a database to offer sound files to
> users using streaming methods.
>
> the request page has options, allowing the user to modify the sound
> file in various ways, before having it sent to them
>
> Here's the problem:
>
> The method i'm using to feed the data to the user is to run the source
> file through various piped commands, with the resulting audio being
> dumped to stdout, and then using passthru in php to get that data to
> the enduser.
>
> here's an example, for serving an MP3 with its pitch/speed changed by sox:
>
> passthru("lame --quiet --decode \"" . $in_file . "\" - | " .
> "sox -V -S -t wav - -t wav - speed " . $speed_factor . " | "
.
> "lame --quiet " . $lame_params . " - -");
>
> This works just fine, except the problem is if the end user aborts the
> transfer (e.g. stops playback in the media player, cancels download of
> the mp3, whatever) then it leaves behind both the sox process and the
> decoder LAMe process along with the sh that's running them. the only
> process that exits is the final encoding lame process. If the sound
> file runs to completion, everythign exits properly.
>
> But this obviously means enough "cancelling" of downloads means the
> server ends up with a huge batch of stuck processes! And I even tried
> simply killing the 'host' sh process, and the lame and sox processes
> remain anyway. The only way I've been able to deal with this is
> manually killing the lame and sox processes directly.
>
> is there any way I can make this work, such so that if the user
> cancels the transfer, all relavent processes are killed rather than
> just the single process that's feeding output into php?
Use something else to pass the data back to the user... popen() comes to
mind or proc_open(). Then disable auto abort on user disconnect via
ignore_user_abort(). Then after sending periodic data chunks, check the
user connection status via connection_aborted(). If your script finds
that the user has aborted, then kill all the processes in the pipeline
from the PHP script before finally aborting the PHP script itself.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "Robert Cummings" <[email protected]>
To: "flint" <[email protected]>
Cc: "PHP-General List" <[email protected]>
Sent: Sunday, May 31, 2009 10:15 PM
Subject: Re: [PHP] spawning a process that uses pipes - doesn't
terminatewhen webpage download is canceled
I'm already doing something like that... here's what I have basically
$o = popen($cmd);
while (!feof($o)) {
$buffer = fread($o,4096);
echo $p;
}
exit();
Ok so I can add in the statements to stop auto aborting, use connection
aborted... but how do i kill the process chain itself? If I simply pclose
the process it has the same effect - the other spawned processes keep
running. I figured out what's happening is the lame process keeps going
utnil it finishes, and apparently is sending its data to the proverbial bit
bucket... and in a process tree it moves from being under the http process
to being under init itself...
fm
Use something else to pass the data back to the user... popen() comes to
mind or proc_open(). Then disable auto abort on user disconnect via
ignore_user_abort(). Then after sending periodic data chunks, check the
user connection status via connection_aborted(). If your script finds
that the user has aborted, then kill all the processes in the pipeline
from the PHP script before finally aborting the PHP script itself.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
On Sun, 2009-05-31 at 21:23 -0700, bruce wrote:
> hi robert.,,
>
> now you've got me curious..
>
> you state...
>
> -Use something else to pass the data back to the user... popen() comes to
> -mind or proc_open(). Then disable auto abort on user disconnect via
> -ignore_user_abort(). Then after sending periodic data chunks, check the
> -user connection status via connection_aborted(). If your script finds
> -that the user has aborted, then kill all the processes in the pipeline
> -from the PHP script before finally aborting the PHP script itself.
>
> but if the user is using a browser session... which has a web server
> connection... are you siggesting that the server app spawns off a child
> process via the popen, and that the child somehow connects to the existing
> browser session??
>
> walk through the psuedo logic/flow of this if you don't mind.. i must be
> missing something..
The PHP session controls the popen() or proc_open() session. The PHP
session can detect that the user has aborted and then shutdown the
popen() or proc_open() processes.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
On Mon, 2009-06-01 at 05:15 -0500, flint wrote:
> ----- Original Message -----
> From: "Robert Cummings" <[email protected]>
> To: "flint" <[email protected]>
> Cc: "PHP-General List" <[email protected]>
> Sent: Sunday, May 31, 2009 10:15 PM
> Subject: Re: [PHP] spawning a process that uses pipes - doesn't
> terminatewhen webpage download is canceled
>
> I'm already doing something like that... here's what I have basically
>
> $o = popen($cmd);
> while (!feof($o)) {
> $buffer = fread($o,4096);
> echo $p;
> }
> exit();
>
> Ok so I can add in the statements to stop auto aborting, use connection
> aborted... but how do i kill the process chain itself? If I simply pclose
> the process it has the same effect - the other spawned processes keep
> running. I figured out what's happening is the lame process keeps going
> utnil it finishes, and apparently is sending its data to the proverbial bit
> bucket... and in a process tree it moves from being under the http process
> to being under init itself...
You can use the linux shell command ps:
exec( 'ps --ppid '.getmypid(), $children );
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
hi robert...
i got the popen/php process but i don't see how one can stop a
browser/apache process, and somehow reattach to the browser process.. unless
he's talking about stopping a process within the app's context.. and then
contniuing..
-----Original Message-----
From: Robert Cummings [mailto:[email protected]]
Sent: Monday, June 01, 2009 5:46 AM
To: bruce
Cc: 'flint'; 'PHP-General List'
Subject: RE: [PHP] spawning a process that uses pipes -
doesn'tterminatewhen webpage download is canceled
On Sun, 2009-05-31 at 21:23 -0700, bruce wrote:
> hi robert.,,
>
> now you've got me curious..
>
> you state...
>
> -Use something else to pass the data back to the user... popen() comes to
> -mind or proc_open(). Then disable auto abort on user disconnect via
> -ignore_user_abort(). Then after sending periodic data chunks, check the
> -user connection status via connection_aborted(). If your script finds
> -that the user has aborted, then kill all the processes in the pipeline
> -from the PHP script before finally aborting the PHP script itself.
>
> but if the user is using a browser session... which has a web server
> connection... are you siggesting that the server app spawns off a child
> process via the popen, and that the child somehow connects to the existing
> browser session??
>
> walk through the psuedo logic/flow of this if you don't mind.. i must be
> missing something..
The PHP session controls the popen() or proc_open() session. The PHP
session can detect that the user has aborted and then shutdown the
popen() or proc_open() processes.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Mon, 2009-06-01 at 07:52 -0700, bruce wrote:
> hi robert...
>
> i got the popen/php process but i don't see how one can stop a
> browser/apache process, and somehow reattach to the browser process.. unless
> he's talking about stopping a process within the app's context.. and then
> contniuing..
Hi Bruce,
He's spawning child processes to handle the audio changes. These
processes are separate processes from the PHP script being run by the
webserver. However, they are children of the PHP script process since
they have been started by the PHP script via popen() or proc_open(). His
problem is that when the user changes page mid load, or shuts down the
browser, the PHP script (the parent) is killed off by the webserver, but
the child processes, sox and lame, continue to run. This ends up
polluting CPU/memory with useless processes. What he wants is to have
these processes also die. So by using proc_open() he can retrieve the
output from the processes he has started and send that to the connected
browser in chunks, but also detect if the browser has dropped its
connection in which case he can manually kill of the child processes
that aren't being killed automatically. HTH.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
Hello,
on 05/28/2009 10:20 AM Olexandr Heneralov said the following:
> Hi!
> Guys, you of course, know that ASP.NET becomes more and more popular in the
> world.
> I have a question for everyone:
> Can it happen so that PHP will be replaced with ASP.NET?
ASP.NET is not a language. It is more like a framework that can run
multiple languages. It can run VB.NET, C# and even PHP (although it is
not usual).
I am not sure what are the current numbers, but the latest statistics
that I have seen Apache was running on 72% of the Internet Web servers
against only 17% of Microsoft IIS. Although you can run ASP.NET on
Apache via mono, that is unusual.
Also PHP is the most popular Apache extension present in between 40% and
50% of Apache installations. This means that PHP is present in 1/3 of
the Internet Web servers, which represents about half of the PHP market
share.
This article provides more details about PHP market share.
http://www.phpclasses.org/blog/post/95-How-large-is-the-PHP-market.html
As of ASP.NET becoming more popular than PHP, I don't think that even
Microsoft believes that is possible. Actually Microsoft is very
concerned that PHP runs well on Windows and is sponsoring a lot of PHP
activity.
This other article talks about what is Microsoft so interested in PHP now.
http://www.phpclasses.org/blog/post/85-What-is-Microsoft-up-to-with-PHP.html
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
On Mon, Jun 1, 2009 at 12:30 AM, Manuel Lemos <[email protected]> wrote:
> Hello,
>
> on 05/28/2009 10:20 AM Olexandr Heneralov said the following:
>> Hi!
>> Guys, you of course, know that ASP.NET becomes more and more popular in the
>> world.
>> I have a question for everyone:
>> Can it happen so that PHP will be replaced with ASP.NET?
>
> ASP.NET is not a language. It is more like a framework that can run
> multiple languages. It can run VB.NET, C# and even PHP (although it is
> not usual).
>
> I am not sure what are the current numbers, but the latest statistics
> that I have seen Apache was running on 72% of the Internet Web servers
> against only 17% of Microsoft IIS.
I think the two are closer than that. Netcraft has had Apache at
around 45% and Microsoft IIS at around 30% for a couple years now.
> Also PHP is the most popular Apache extension present in between 40% and
> 50% of Apache installations. This means that PHP is present in 1/3 of
> the Internet Web servers, which represents about half of the PHP market
> share.
PHP is also available on IIS. A slightly better measure *might* be the
approach Dan mentioned a while back where he queried Google to count
the number of pages indexed by suffix. Even so, you know what they say
about statistics....
Will ASP.NET replace PHP? Time will tell. (I doubt it.) At any rate,
I'm not losing any sleep over it.
Andrew
--- End Message ---
--- Begin Message ---
> ASP.NET is not a language. It is more like a framework that can run
> multiple languages. It can run VB.NET, C# and even PHP (although it is
> not usual).
I'm going to shoot from a (90's?) hip on this one.
Isn't ".NET" the framework, and "<enter_your_language_here>.NET" the language?
ASP.NET uses ASP to access the .NET framework.
VB.NET uses VB to access the .NET framework.
<enter_your_language_here>.NET uses <enter_your_language_here> to
access the .NET framework.
And how _IS_ Mono coming along? Last I checked, 1.x stuff worked on
Linux, but the goodies I wanted were in the 2.x framework.
--- End Message ---
--- Begin Message ---
Hi
I am creating a birthday calendar of all my friends and family. Can you please
click on the link below to enter your birthday for me?
http://www.birthdayalarm.com/bd2/85206071a420999425b1469532889c603775600d905
Thanks,
Jacob
--- End Message ---
--- Begin Message ---
On Mon, Jun 1, 2009 at 00:55, Jacob Kutty <[email protected]> wrote:
> Hi
>
> I am creating a birthday calendar of all my friends and family. Can you
> please click on the link below to enter your birthday for me?
>
> http://www.birthdayalarm.com/bd2/85206071a420999425b1469532889c603775600d905
Please do not send such automated crap to these lists or you will be banned.
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000
--- End Message ---
--- Begin Message ---
how do I make a permanent connection to mysql database and what is
difference between mysql_connect() and permanent one?
If I make connections in one file and redirect it to another file do
I keep connection (permanent / standard)?
Do I lose connection only when I type mysql_close (permanent/ standard)?
if I select different database between the php program do I need to do
something extra along mysql_select_db("dbname",$link)?
If I opened db in another php file, where do I get the $link variable
from = mysql_connect (when selecting another database)?
Thanks in advance,
--
When the sun rises I receive and when it sets I forgive ->
http://users.skavt.net/~gleskovs/
All the Love, Grega Leskov'sek
--- End Message ---
--- Begin Message ---
Hi
Anyone know whats the best way to learn PHP? Every time I open an php book
or look the codes online, my mind goes "oh man, So many stuffs to learn and
gets frustrated before i even start" but on the other hand, I don't know why
some how the brain keep on nagging me to learn PHP. I guess what's the fun
way to learn php? Any good books?
--- End Message ---
--- Begin Message ---
I don't think there are any substitutes for good books but
www.phpvideotutorials.com has screencasts. I have really enjoyed them.
There are free ones and paid ones. If funds permit I would recommend the
paid ones, there are hours and hours of them. It does not work out to be
much at all per hour. The free ones are of course the place to start
however.
-Patrick
Muhammad Hassan Samee wrote:
> Hi
>
> Anyone know whats the best way to learn PHP? Every time I open an php book
> or look the codes online, my mind goes "oh man, So many stuffs to learn and
> gets frustrated before i even start" but on the other hand, I don't know why
> some how the brain keep on nagging me to learn PHP. I guess what's the fun
> way to learn php? Any good books?
>
>
--- End Message ---
--- Begin Message ---
Muhammad Hassan Samee wrote:
Hi
Anyone know whats the best way to learn PHP? Every time I open an php book
or look the codes online, my mind goes "oh man, So many stuffs to learn and
gets frustrated before i even start" but on the other hand, I don't know why
some how the brain keep on nagging me to learn PHP. I guess what's the fun
way to learn php? Any good books?
Start with something small, like maintaining a database of your personal
book collection - and learn to administer a DB (IE MySQL) at the same time.
--- End Message ---
--- Begin Message ---
Muhammad Hassan Samee wrote:
Hi
Anyone know whats the best way to learn PHP? Every time I open an php book
or look the codes online, my mind goes "oh man, So many stuffs to learn and
gets frustrated before i even start" but on the other hand, I don't know why
some how the brain keep on nagging me to learn PHP. I guess what's the fun
way to learn php? Any good books?
read the manual from start to finish, and try all examples.
by the time you've done that you'll know php
--- End Message ---
--- Begin Message ---
On Mon, 1 Jun 2009 15:43:21 +0500
Muhammad Hassan Samee <[email protected]> wrote:
> Hi
>
> Anyone know whats the best way to learn PHP? Every time I open an php
> book or look the codes online, my mind goes "oh man, So many stuffs
> to learn and gets frustrated before i even start" but on the other
> hand, I don't know why some how the brain keep on nagging me to learn
> PHP. I guess what's the fun way to learn php? Any good books?
Do you already code?
If so, just download something you are interested in, maybe WordPress
if you blog, with some plugins as those are most likely easier to read,
and look at the programs and try figuring out why things are working
they way they work.
I can't really remember how I started but I believe it was with
Postnuke a long time ago. I looked at the code, try to help fix bugs.
The best way to learn any language, computer or natural, is not by
sitting down and reading books, it's by actually programming/speaking
the language.
--
Peter van der Does
GPG key: E77E8E98
IRC: Ganseki on irc.freenode.net
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Jabber ID: [email protected]
GetDeb Package Builder
http://www.getdeb.net - Software you want for Ubuntu
--- End Message ---
--- Begin Message ---
On 6/1/09 6:43 AM, "Muhammad Hassan Samee" <[email protected]> wrote:
> Anyone know whats the best way to learn PHP? Every time I open an php book
> or look the codes online, my mind goes "oh man, So many stuffs to learn and
> gets frustrated before i even start" but on the other hand, I don't know why
> some how the brain keep on nagging me to learn PHP. I guess what's the fun
> way to learn php? Any good books?
i've often tried to learn a language from a book and always failed. clearly
this works for some folk, never has for me.
i find the initial ramp of the learning curve very hard to take. it's
daunting. but that's always true and anything really worth your time is
going to be difficult.
after doing hello world, think of a simple project of your own to tinker
with as you learn.
that's the generalities. as for php, if you already know a few programming
languages, i think the the manual's chapter called "language reference" is
not a bad place to start. lots of examples. systematic one language feature
at a time. skip stuff that really makes no sense, you can lear those bits
later. you'll forget most of it but you'll know where to find it when you
need it. try things out in your sample project.
once you're programming and getting stuff done, reading other people's code
is great. there's lots available (e.g. in pear). but don't assume it's all a
model for what you should do, it's just examples of what can be done --
good, bad and indifferent.
good luck
--- End Message ---
--- Begin Message ---
Hey,
I would like to know how I can instantiate the types that I get via the
__getTypes() function or know if this is even possible.
I am asking because I have a webservice in which all functions expect an
specific object to be passed to them, rather than a list of arguments.
And I am hoping that I do not have to code all those objects into my PHP
Code, but rather instantiate them kinda from the wsdl!
Here is what I have:
$map = array('Credentials' => 'Credentials', 'GetSourceTextRequest'
=> 'GetSourceTextRequest');
$ws = new SoapClient('http://192.168.0.1:8080/Service?wsdl',
array('classmap' => $map));
$test = new GetSourceTextRequest();
It does not work this way however, I do get a class not found failure.
How can I instantiate an object from SOAP?
__getTypes() gives me something like this:
struct Credentials {
string Password;
string Username;
}
Any hints would be appreciated!
Regards,
Samy
--- End Message ---
--- Begin Message ---
As continuation to my last question, I got another one.
a brief summary:
I had to process a file that contains 700,000 lines,
each line contained some data (lets assume each line was like:
name|age|work|lastaccessed
)
age contains the person's age in time() format, how many seconds has past
since he was born.
lastaccessed contains also a time(), with his last access.
work is some text, also is name. )
so I inserted it (with stacked queries),
My question is - lets assume I get a new file, and I need to compare the
changes - how would you suggest me to do it?
Assuming that if the new file has more lines I should insert (and of course
know about it so I can notify the user),
and assuming the new file has less lines - I should delete (and of course
know about it so I can notify the user).
I also don't have the old file.
I have no idea that is fast enough (less then 30 minutes. Insertion took
about 10 minutes).
What's your idea?
--
Use ROT26 for best security
--- End Message ---
--- Begin Message ---
On Sat, May 30, 2009 at 1:51 PM, Eddie Drapkin <[email protected]> wrote:
> Hey, I'm looking to start playing with 5.3.0, and thus by extension,
> namespaces. One of the things that I definitely need support for is
> autoloading, and the docs aren't exactly explicit in some (obvious to me)
> cases.
>
> I have an autoloading class that internally handles file-not-found errors
> and the like and a set of methods that get registered via
> spl_autoload_register. I'm wondering if there's any way that the
> autoloader
> - which won't exist inside a namespace - can handle classes with the same
> name in several different namespaces. Say, for example, I have three
> directories foo/, bar/, and baz/ and each of those corresponds to a
> same-named namespace, and each also has a class named ExampleClass. If I
> try to instantate a foo\ExampleClass, does the classname get set in the
> autoloader method as "ExampleClass" or "foo\ExampleClass"? If the former,
> is there any way to determine the namespace name so I don't accidentally
> autoload bar\ExampleClass or baz\ExampleClass?
>
i seem to remember a while back, someone saying the entire namespace will
now be passed into the __autoload() function, whereas before it was just the
classname. your autoload logic should be equipped to handle different
classes w/ the same name, in different namespaces.
-nathan
--- End Message ---