Re: [PHP-DEV] Is there any value in having functions defined whichdo nothing.

2001-07-10 Thread Stig Bakken

yes it would be better to not define it.  that has been "the way" in php 3
and 4.  only back in v2 we had those "blah is not enabled" messages.

 - Stig

On Tue, 10 Jul 2001, Jeremy Bettis wrote:

> Why is the habit of PHP modules to define functions that might or might not
> work depending on library dependancies.
> 
> For example, ImageCopyResampled gives this error if libgd < 2.0:
> "ImageCopyResampled required libgd 2.0"
> 
> But that makes this code useless:
> 
> if (function_exists('ImageCopyResampled')) {
> // doit the good way
> ImageCopyResampled(.);
> } else {
> ImageCopyResized(.);
> }
> 
> My point was to have the php script work regardless of what version of php
> was installed, but even if the function exists, it might not work.  Wouldn't
> it have been better if the function just didn't exist at all?
> --
> Jeremy Bettis
> [EMAIL PROTECTED]
> 
> 
> 
> -- 
> PHP Development Mailing List 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Is there any value in having functions defined whichdo nothing.

2001-07-10 Thread Joao Prado Maia


On Tue, 10 Jul 2001, Jeremy Bettis wrote:

> Why is the habit of PHP modules to define functions that might or might not
> work depending on library dependancies.
>
> For example, ImageCopyResampled gives this error if libgd < 2.0:
> "ImageCopyResampled required libgd 2.0"
>
> But that makes this code useless:
>
> if (function_exists('ImageCopyResampled')) {
> // doit the good way
> ImageCopyResampled(.);
> } else {
> ImageCopyResized(.);
> }
>
> My point was to have the php script work regardless of what version of php
> was installed, but even if the function exists, it might not work.  Wouldn't
> it have been better if the function just didn't exist at all?

Thats a very good question. I stumbled across a similar problem a few
weeks ago - I was trying to check for TTF support on the GD module, but
using function_exists() on ImageTTFBBOx for instance showed that the
function was there, but you couldn't use because it was outputting a
warning about the lack of TTF support.

Since this problem is not going away anytime soon, I suggest you check for
the return value of those functions, and then use the alternate one if
needed. Thats what I'm doing right now and it seems to be the most
compatible way as of now.

Cheers,
Joao

--
João Prado Maia <[EMAIL PROTECTED]>
http://phpbrasil.com - php com um jeitinho brasileiro
--
Precisando de consultoria em desenvolvimento para a Internet ?
Impleo.net - http://impleo.net/?lang=br


--
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]