php-general Digest 5 Jul 2008 21:40:48 -0000 Issue 5552
Topics (messages 276296 through 276320):
Asynchronous PHP Execution
276296 by: Waynn Lue
276299 by: Richard Heyes
276310 by: Shawn McKenzie
276311 by: Richard Heyes
276314 by: Shawn McKenzie
276315 by: Shawn McKenzie
276316 by: Shawn McKenzie
276317 by: Daniel Brown
Re: Scrambling a word
276297 by: Richard Heyes
first e-shop
276298 by: Alain Roger
276304 by: Bastien Koert
276306 by: Wolf
odbc msaccess php5
276300 by: Peter Jackson
276305 by: Bastien Koert
276307 by: Bastien Koert
Re: Trying to keep a dropdown selection sticky
276301 by: Peter Jackson
Re: Installed 5.2.6 but phpinfo() still says 5.0.2
276302 by: Colin Guthrie
Re: Creating XML files
276303 by: Per Jessen
Re: Trying to keep a dropdown selection sticky [solved] - Forgive the length of
message, please
276308 by: Michael S. Dunsavage
276313 by: tedd
PHP and SAP
276309 by: robert mena
class_is_loadable?
276312 by: Larry Garfield
276318 by: Pulni4kiya
276319 by: Larry Garfield
276320 by: Pulni4kiya
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 have a system where a user clicks on a button which causes rows to
be inserted in to the database. I'd also like to run some lengthier
post-processing on those rows, but don't want to put it in the
critical path of the rows being inserted and returning to the user.
What's the best way to either batch up these other actions, or pass
them to a thread or other asynchronous process to do the second part
of the action?
I've thought about using a queue, either backed by a FIFO file (which
is proving somewhat difficult) or MySQL, and exec/shell (but that
doesn't seem to be asynchronous), but neither seems optimal.
Does anyone have any suggestions?
Thanks,
Waynn
--- End Message ---
--- Begin Message ---
> and exec/shell (but that
doesn't seem to be asynchronous), but neither seems optimal.
It can be if you redirect the output streams and put an ampersand after it:
<?php
exec('sleep 5 > /dev/null 2>/dev/null &');
echo 'Script ended';
?>
This tiny sample should end immediately, and the sleep command should
run on regardless.
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
> and exec/shell (but that
doesn't seem to be asynchronous), but neither seems optimal.
It can be if you redirect the output streams and put an ampersand after it:
<?php
exec('sleep 5 > /dev/null 2>/dev/null &');
echo 'Script ended';
?>
This tiny sample should end immediately, and the sleep command should
run on regardless.
Also:
exec('sleep 5 >& /dev/null &');
Maybe?
-Shawn
--- End Message ---
--- Begin Message ---
Also:
exec('sleep 5 >& /dev/null &');
Maybe?
Two ampersands you mean? Why - what does it do? You're also not
redirecting STDERR.
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
Also:
exec('sleep 5 >& /dev/null &');
Maybe?
Two ampersands you mean? Why - what does it do? You're also not
redirecting STDERR.
My bad. I was trying to shorten your command. >& redirects stdout and
stderr, unfortunately in c shell though.
-Shawn
--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
Also:
exec('sleep 5 >& /dev/null &');
Maybe?
Two ampersands you mean? Why - what does it do? You're also not
redirecting STDERR.
I can't always remember because I think some things that are in c shell
but aren't available in bourne have been incorpoated into bash. So I
think in bourne/bash: >/dev/null 2>&1 and the >& may work in bash,
I'll have to check.
-Shawn
--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
Also:
exec('sleep 5 >& /dev/null &');
Maybe?
Two ampersands you mean? Why - what does it do? You're also not
redirecting STDERR.
I can't always remember because I think some things that are in c shell
but aren't available in bourne have been incorpoated into bash. So I
think in bourne/bash: >/dev/null 2>&1 and the >& may work in bash,
I'll have to check.
-Shawn
--- End Message ---
--- Begin Message ---
On Sat, Jul 5, 2008 at 6:01 AM, Waynn Lue <[EMAIL PROTECTED]> wrote:
> I have a system where a user clicks on a button which causes rows to
> be inserted in to the database. I'd also like to run some lengthier
> post-processing on those rows, but don't want to put it in the
> critical path of the rows being inserted and returning to the user.
> What's the best way to either batch up these other actions, or pass
> them to a thread or other asynchronous process to do the second part
> of the action?
Can you just run this via a cron or Scheduled Task? Just have a
boolean column that distinguishes new rows as unprocessed, and flip
the flag when the cron script processes the row.
--
</Daniel P. Brown>
Sent from an airport terminal in Cincinnati Airport, waiting for a
flight back to Scranton, Pa.
--- End Message ---
--- Begin Message ---
Using an empty delimeter with explode leads to a php warning. At least
in the php versions i worked with. Still there is a similar function:
<?php
var_dump(chunk_split('test', 1, ' '));
Odd. Don't know where that idea came from then.
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
--- End Message ---
--- Begin Message ---
Hi,
I need to create an e-shop in PHP.
this is for me the first time that i need to do that and i think the way how
to approach such topic is different that creating a simple corporate web
site.
Here are the standard features that i need to implement:
- home page including latest "article/news", offers, discounts, material
tests
e-shop should:
- allow users to search good by selecting a category (and/or sub category)
or by specifying parameters in search tool
- allow users to browse goods
- catalog of good should be browsable offering a short description of the
good, name of good, picture, price and link to more detailed information
- allow basket usage for ordering goods.
- allow payment by several using different methods (credit cards, paypal,
and so on...)
Administrative part of the web site should also:
- allow archivings of old article/news, and material/good tests
- allow composing of articles, tests, and so on... including pictures page
setup.
- allow management of goods and catalog.
as you can see something really standard... however, i would like to do it
well from the beginning, so i would like to know if some example or tutorial
(even if partial) exist on internet..
and for sure,, you are experienced in such topics, so to what should i pay
attention ?
thanks a lot,
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008
--- End Message ---
--- Begin Message ---
On Sat, Jul 5, 2008 at 6:26 AM, Alain Roger <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I need to create an e-shop in PHP.
> this is for me the first time that i need to do that and i think the way
> how
> to approach such topic is different that creating a simple corporate web
> site.
>
> Here are the standard features that i need to implement:
> - home page including latest "article/news", offers, discounts, material
> tests
>
> e-shop should:
> - allow users to search good by selecting a category (and/or sub category)
> or by specifying parameters in search tool
> - allow users to browse goods
> - catalog of good should be browsable offering a short description of the
> good, name of good, picture, price and link to more detailed information
> - allow basket usage for ordering goods.
> - allow payment by several using different methods (credit cards, paypal,
> and so on...)
>
> Administrative part of the web site should also:
> - allow archivings of old article/news, and material/good tests
> - allow composing of articles, tests, and so on... including pictures page
> setup.
> - allow management of goods and catalog.
>
> as you can see something really standard... however, i would like to do it
> well from the beginning, so i would like to know if some example or
> tutorial
> (even if partial) exist on internet..
> and for sure,, you are experienced in such topics, so to what should i pay
> attention ?
>
> thanks a lot,
>
> --
> Alain
> ------------------------------------
> Windows XP SP2
> PostgreSQL 8.2.4 / MS SQL server 2005
> Apache 2.2.4
> PHP 5.2.4
> C# 2005-2008
>
check out www.hotscripts.com or http://sourceforge.net for prebuilt sytems
--
Bastien
Cat, the other other white meat
--- End Message ---
--- Begin Message ---
Alain Roger wrote:
Hi,
I need to create an e-shop in PHP.
this is for me the first time that i need to do that and i think the way how
to approach such topic is different that creating a simple corporate web
site.
STFW: php: open source e-commerce
http://www.google.com/search?q=php%3A+open+source+e-commerce&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
--- End Message ---
--- Begin Message ---
Hi list,
I am trying to get info out of a MS Access 2000 db. So far I have
managed to do some of it but current part has me stumped.
Set up
Machine 1 - Debian 4, Apache, PHP5 unixodbc, mdbtools
Machine 2 - WindowsXP, MS-Access
Database is in a windows share that is smfs mounted on the linux box.
$conn=odbc_connect("Database","",""); works
$a = "abcd"; (this value exists in db)
$stat = "Select * FROM " . '"Table Name"';
$qry = odbc_exec($conn,$stat);
$res = odbc_result_all($qry) or die("Error: ");
The above works as I expect it to.(Returns 70 rows)
If I now want to add a where clause
$stat = "SELECT * FROM " . '"Table Name"' . " Where " . '"Column Name" =
" . $a; (This works)
Now the place I fall into the abyss.
if I change WHERE clause in $stat to
" WHERE " . '"Column Name"' LIKE abc* (or other variations like abc%
"abc%" "abc*" 'abc%' 'abc*')
All I end up with is a blank page or Warning odbc_result_all No tuples
available at this result index.
Also I'm having trouble working out how to use a date in the WHERE
clause. I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and
yy/mm/dd 00:00:00 etc
I realize this is probably more odbc/sql related but after a lot of
goggling and reading I havent found the answer (about 5 days so far)
And before everyone shouts use mySQL postgresql etc that isnt an option
at this point in time. I dont need to update the records I just need to
be able to read them with php.
Oh and whilst I'm here is it possible to read an ms-query via odbc?
(eg select * from myquery). Just thinking that may fix one of my
problems (Caps and spaces in table/column names aaarrgghh)
Peter Jackson
--- End Message ---
--- Begin Message ---
On Sat, Jul 5, 2008 at 6:51 AM, Peter Jackson <[EMAIL PROTECTED]>
wrote:
> Hi list,
>
> I am trying to get info out of a MS Access 2000 db. So far I have managed
> to do some of it but current part has me stumped.
>
> Set up
> Machine 1 - Debian 4, Apache, PHP5 unixodbc, mdbtools
> Machine 2 - WindowsXP, MS-Access
>
> Database is in a windows share that is smfs mounted on the linux box.
>
> $conn=odbc_connect("Database","",""); works
> $a = "abcd"; (this value exists in db)
> $stat = "Select * FROM " . '"Table Name"';
> $qry = odbc_exec($conn,$stat);
> $res = odbc_result_all($qry) or die("Error: ");
>
> The above works as I expect it to.(Returns 70 rows)
>
> If I now want to add a where clause
> $stat = "SELECT * FROM " . '"Table Name"' . " Where " . '"Column Name" = "
> . $a; (This works)
>
> Now the place I fall into the abyss.
> if I change WHERE clause in $stat to
> " WHERE " . '"Column Name"' LIKE abc* (or other variations like abc%
> "abc%" "abc*" 'abc%' 'abc*')
> All I end up with is a blank page or Warning odbc_result_all No tuples
> available at this result index.
>
> Also I'm having trouble working out how to use a date in the WHERE clause.
> I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and yy/mm/dd 00:00:00
> etc
> I realize this is probably more odbc/sql related but after a lot of
> goggling and reading I havent found the answer (about 5 days so far)
> And before everyone shouts use mySQL postgresql etc that isnt an option at
> this point in time. I dont need to update the records I just need to be able
> to read them with php.
>
> Oh and whilst I'm here is it possible to read an ms-query via odbc?
> (eg select * from myquery). Just thinking that may fix one of my problems
> (Caps and spaces in table/column names aaarrgghh)
>
> Peter Jackson
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
As the data seems to be text based, you need to quote it
WHERE " . '"Column Name"' LIKE 'abc%'
--
Bastien
Cat, the other other white meat
--- End Message ---
--- Begin Message ---
On Sat, Jul 5, 2008 at 11:04 AM, Bastien Koert <[EMAIL PROTECTED]> wrote:
>
>
> On Sat, Jul 5, 2008 at 6:51 AM, Peter Jackson <[EMAIL PROTECTED]>
> wrote:
>
>> Hi list,
>>
>> I am trying to get info out of a MS Access 2000 db. So far I have
>> managed to do some of it but current part has me stumped.
>>
>> Set up
>> Machine 1 - Debian 4, Apache, PHP5 unixodbc, mdbtools
>> Machine 2 - WindowsXP, MS-Access
>>
>> Database is in a windows share that is smfs mounted on the linux box.
>>
>> $conn=odbc_connect("Database","",""); works
>> $a = "abcd"; (this value exists in db)
>> $stat = "Select * FROM " . '"Table Name"';
>> $qry = odbc_exec($conn,$stat);
>> $res = odbc_result_all($qry) or die("Error: ");
>>
>> The above works as I expect it to.(Returns 70 rows)
>>
>> If I now want to add a where clause
>> $stat = "SELECT * FROM " . '"Table Name"' . " Where " . '"Column Name" =
>> " . $a; (This works)
>>
>> Now the place I fall into the abyss.
>> if I change WHERE clause in $stat to
>> " WHERE " . '"Column Name"' LIKE abc* (or other variations like abc%
>> "abc%" "abc*" 'abc%' 'abc*')
>> All I end up with is a blank page or Warning odbc_result_all No tuples
>> available at this result index.
>>
>> Also I'm having trouble working out how to use a date in the WHERE clause.
>> I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and yy/mm/dd 00:00:00
>> etc
>> I realize this is probably more odbc/sql related but after a lot of
>> goggling and reading I havent found the answer (about 5 days so far)
>> And before everyone shouts use mySQL postgresql etc that isnt an option at
>> this point in time. I dont need to update the records I just need to be able
>> to read them with php.
>>
>> Oh and whilst I'm here is it possible to read an ms-query via odbc?
>> (eg select * from myquery). Just thinking that may fix one of my problems
>> (Caps and spaces in table/column names aaarrgghh)
>>
>> Peter Jackson
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> As the data seems to be text based, you need to quote it
>
> WHERE " . '"Column Name"' LIKE 'abc%'
>
> --
>
> Bastien
>
> Cat, the other other white meat
sorry, missed the access dates...
try mm/dd/yyyy as the format
--
Bastien
Cat, the other other white meat
--- End Message ---
--- Begin Message ---
Michael S. Dunsavage wrote:
I have a form I want to keep sticky, but I can't figure out how. I got
all the <INPUT>'s to be sticky....
The select script
<?php
echo '<strong>State</strong><br>';
echo '<select name="State">';
foreach ($state_list as $key => $value) {
echo "<option value=\"$key\"> $value</option>\n";
}
echo '</select>';
echo '<br>';
?>
If I'm reading this correctly you mean if the value has been selected
before select it again?
If so way I did it was by checking the database value
eg
echo "<option value=\"$key\"
if ($row[id] == $key) {
print "SELECTED"; }
echo "> $value </option>\n";
Peter Jackson
--- End Message ---
--- Begin Message ---
David Robley wrote:
x0ml wrote:
For some reason this first post didn't "post" to this newsgroup...
"x0ml" <[EMAIL PROTECTED]> wrote in message news:...
I've installed PHP version 5.2.6 but phpinfo() and php -v both report
back the old version 5.0.2.
You did restart the server after making the changes?
Doesn't really matter as he said php -v reports things incorrectly too.
I reckon the whole ./configure sans prefix and thus defaulting to
/usr/local is the most likely issue....
Col
--- End Message ---
--- Begin Message ---
It flance wrote:
> Some months ago i worked with XML. And i remember that i was able to
> create xml files quite easily. Now i don`t have the book i used by the
> time. I made many searches in google and i don't find something
> interesting. So i'm wondering if somebody can give a good link with
> examples. If i remeber well, i can create axml file without writing
> the hole file to a string before writing the string to the file.
Creating XML files is quite easy with vi or any other editor. In PHP,
you can just write XML with fwrite().
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
On Sat, 2008-07-05 at 21:30 +1000, Peter Jackson wrote:
> Michael S. Dunsavage wrote:
> > I have a form I want to keep sticky, but I can't figure out how. I got
> > all the <INPUT>'s to be sticky....
> >
> > The select script
> >
> >
> > <?php
> > echo '<strong>State</strong><br>';
> > echo '<select name="State">';
> > foreach ($state_list as $key => $value) {
> > echo "<option value=\"$key\"> $value</option>\n";
> > }
> > echo '</select>';
> > echo '<br>';
> >
> >
> >
> > ?>
> >
>
> If I'm reading this correctly you mean if the value has been selected
> before select it again?
> If so way I did it was by checking the database value
> eg
> echo "<option value=\"$key\"
> if ($row[id] == $key) {
> print "SELECTED"; }
> echo "> $value </option>\n";
>
> Peter Jackson
What I mean is when the users clicks submit, and the form is handled and
some information is lacking, it retains what information was given.
What I eventually did was:
foreach($state_list as $key=>$value){
if($selected_state == $key){
$sel = 'selected="selected"';
}
else{
$sel = '';
}
echo "<option $sel value=\"$key\">$value</option>";
}
echo '</select>';
?>
And then put
if (!empty($_POST))
{
$selected_state = $_POST['State'];
}
At the beginning of the scripts.
Full script:
<?php
if (!empty($_POST))
{
$selected_state = $_POST['State'];
}
if (isset($_POST['SUBMIT'])) { // Handle the form.
$message = NULL; // Create an empty new variable.
// Check for a name.
if (strlen($_POST['FirstName']) > 0) {
$FirstName = TRUE;
} else {
$FirstName = FALSE;
$message .= '<p>You forgot to enter your first name.</p>';
}
if (strlen($_POST['LastName']) > 0) {
$LastName = TRUE;
} else {
$LastName = FALSE;
$message .= '<p>You forgot to enter your last name.</p>';
}
// Check for an email address.
if (strlen($_POST['Email']) > 0) {
$Email = TRUE;
} else {
$Email = FALSE;
$message .= '<p>You forgot to enter your email address.</p>';
}
//Check for Address
if (strlen($_POST['Address']) > 0) {
$Address = TRUE;
} else {
$AddreSS= FALSE;
$message .= '<p>You forgot to enter your address.</p>';
}
//Check for City
if (strlen($_POST['City']) > 0) {
$City = TRUE;
} else {
$City = FALSE;
$message .= '<p>You forgot to enter your city.</p>';
}
//Check for Zip
if (strlen($_POST['Zip']) > 0) {
$Zip = TRUE;
} else {
$Zip = FALSE;
$message .= '<p>You forgot to enter your zip code.</p>';
}
//Check for Comments
if (strlen($_POST['Comments']) > 0) {
$Commentsbody=$_POST['Comments'];
$Comments = TRUE;
} else {
$Comments = FALSE;
$message .= '<p>You forgot to enter any comments.</p>';
}
if ($FirstName && $LastName && $Email && $Address && $City && $Zip &&
$Comments) { // If everything's okay.
// Register the user.
// Send an email.
$body = "Your comments were: \n\n ' $Commentsbody ' \n\n We will
repsond to your e-mail shortly.\n\nSincerely,\nMSD Computing";
mail ($_POST['Email'], 'Thank you for contacting MSD
Computing.',
$body, 'From: [EMAIL PROTECTED]');
header ('Location: thankyou.php');
exit();
} else {
$message .= '<p>Please try again.</p>';
}
}
$page_title="Contact MSD Computing";
include ('../phpinclude/header.inc');
if (isset($message)) {
echo '<strong></strong><font color="#9B1003" size=4>', $message,
'</font></strong>';
}
?>
--
Michael S. Dunsavage
--- End Message ---
--- Begin Message ---
At 11:31 AM -0400 7/5/08, Michael S. Dunsavage wrote:
What I eventually did was:
-snip-
You might also consider adding a javascript routine to do the same
thing. Why? Because it's a bit quicker doesn't hit the server until
all the fields are filled.
Like this:
http://webbytedd.com/c/form-submit/
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Hi,
I'd like to know if there are any tutorials about SAP and PHP. I'm moving
to a new company and there is the need to provide some sort of access to
internet/intranet to resources available in SAP.
Since I work with PHP I am wondering what kind of support, tips, info I can
get in order to decided if it is the best language or the alternatives.
regards.
--- End Message ---
--- Begin Message ---
Greetings, all.
I am trying to figure out a way to implement the following logic, but I am not
sure if it is possible to do so without a lot of additional side work:
I have a class, A, and another class B that extends A. They live in separate
files. The logic I need to implement is as follows:
if (class_exists('B')) {
$foo = new B();
}
else {
$foo = new A();
}
That is all well and good if both A and B are already loaded and parsed, but I
am using spl_autoload to lazy-load classes as needed. That means the
class_exists() call will return false if B exists but hasn't been included
yet. What I would like to happen is for PHP to include B if it exists or
give a non-fatal error if it doesn't so that I can instantiate A instead.
Ideally, the logic would be something like the following:
try {
$foo = new B(); // Try to autoload B, throw exception if it can't.
}
catch (ClassDoesntExistEvenAfterRunningThroughAutoloadException $e) {
$foo = new A(); // May autoload A at this point, too.
}
// do stuff with $foo
However, as far as I am aware $foo = new B(); will cause a fatal exception if
autoload doesn't find a B.
Does anyone know of a way to achieve the above effect? This is specifically
for PHP 5.2 and later. Thanks.
--
Larry Garfield
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
First of all, I don't think using autoload is recommended.
If you really want to do it that way, you could check if the file which
autoload will try to include exists and if it does, include it and create
your object.
Actually to make the script more safe, after including the file you should
check if the class exists (because the file might exist but not have the
class in it) and only then you can make the object of that class.
I suppose you could throw the exception you want and do it with the
try-catch as you like it :)
Sorry if my English is bad and if didn't get what you want to do.
"Larry Garfield" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Greetings, all.
I am trying to figure out a way to implement the following logic, but I am
not
sure if it is possible to do so without a lot of additional side work:
I have a class, A, and another class B that extends A. They live in
separate
files. The logic I need to implement is as follows:
if (class_exists('B')) {
$foo = new B();
}
else {
$foo = new A();
}
That is all well and good if both A and B are already loaded and parsed,
but I
am using spl_autoload to lazy-load classes as needed. That means the
class_exists() call will return false if B exists but hasn't been included
yet. What I would like to happen is for PHP to include B if it exists or
give a non-fatal error if it doesn't so that I can instantiate A instead.
Ideally, the logic would be something like the following:
try {
$foo = new B(); // Try to autoload B, throw exception if it can't.
}
catch (ClassDoesntExistEvenAfterRunningThroughAutoloadException $e) {
$foo = new A(); // May autoload A at this point, too.
}
// do stuff with $foo
However, as far as I am aware $foo = new B(); will cause a fatal exception
if
autoload doesn't find a B.
Does anyone know of a way to achieve the above effect? This is
specifically
for PHP 5.2 and later. Thanks.
--
Larry Garfield
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On Saturday 05 July 2008 2:25:20 pm Pulni4kiya wrote:
> First of all, I don't think using autoload is recommended.
Why not? I know there is a performance hit for the lookup time, but for the
system I'm working on I have already solved that issue with selective
pre-caching.
> If you really want to do it that way, you could check if the file which
> autoload will try to include exists and if it does, include it and create
> your object.
Well yes, but then I'm not using autoload at all. I may as well just
include_once() and class_exists(), which is what I'm trying to avoid, both
for code cleanliness and performance (include_once() has its own performance
issues).
> Actually to make the script more safe, after including the file you should
> check if the class exists (because the file might exist but not have the
> class in it) and only then you can make the object of that class.
>
> I suppose you could throw the exception you want and do it with the
> try-catch as you like it :)
Again, that's basically just reimplementing autoloading in user-space, which
defeats the purpose.
If I know exactly which autoload routine would be responsible for loading a
given class, can I do the check in that autoload routine and throw an
exception there? Or would that make insanity happen? :-)
--
Larry Garfield
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Well reimplementing autoloading doesn't seem such a bad idea.
With the integrated autoload ...there is one very stupid way of doing what
you want. Something like this (I suppose you know which class is the parent
of the one that is 'missing'):
eval("class $class_name extends THE_PARENT {}");
You can put a field with the actual class name and fill it in the
constructor so you would know if it's the actual class B or just A with a
different name.
(What I just wrote looks very stupid... Don't laugh at me very much please.
:D)
I'll think of something smarter...this is the first thing that came into my
mind.
Btw why is it so important to use autoloading anyway?
--- End Message ---