PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > Re: PHP Image by Default
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: PHP Image by Default

Réponse
 
LinkBack Outils de la discussion
Vieux 30/08/2007, 05h09   #1
Fred Atkinson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Image by Default

On Tue, 28 Aug 2007 16:17:09 +0100, "peter" <submit@flexiwebhost.com>
wrote:

>
>> It returns null, which brings up a blank image.

>
>then you can simply do something such as:-
>
><?PHP
>$image = getRandomImage('LL/');
>if (is_null($image))
>{
> $image = '';// Set to the image you wish
>}
>echo "<img src='$image' height=90 width=120 alt='LL'>";
>?>
>
>in the if statement place the path and name of the image you want to use as
>the image that will be displayed if nothing is returned from the function.
>


When I use this:

<?php
$image = getRandomImage('LL/');
if (is_null($image))
{
$image = 'none.jpg';// Set to the image you wish
}
echo "<img src='$image' height=90 width=120 alt='LL'>";
?>

and pull up the Web page I look at the source and I see this:
<img src='' height=90 width=120 alt='LL'>

As you can see the 'none.jpg' default file is not coded into
the resulting HTML.

Any idea why?

Regards,



Fred

  Réponse avec citation
Vieux 30/08/2007, 05h14   #2
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Image by Default

Fred Atkinson wrote:
> On Tue, 28 Aug 2007 16:17:09 +0100, "peter" <submit@flexiwebhost.com>
> wrote:
>
>>> It returns null, which brings up a blank image.

>> then you can simply do something such as:-
>>
>> <?PHP
>> $image = getRandomImage('LL/');
>> if (is_null($image))
>> {
>> $image = '';// Set to the image you wish
>> }
>> echo "<img src='$image' height=90 width=120 alt='LL'>";
>> ?>
>>
>> in the if statement place the path and name of the image you want to use as
>> the image that will be displayed if nothing is returned from the function.
>>

>
> When I use this:
>
> <?php
> $image = getRandomImage('LL/');
> if (is_null($image))
> {
> $image = 'none.jpg';// Set to the image you wish
> }
> echo "<img src='$image' height=90 width=120 alt='LL'>";
> ?>
>
> and pull up the Web page I look at the source and I see this:
> <img src='' height=90 width=120 alt='LL'>
>
> As you can see the 'none.jpg' default file is not coded into
> the resulting HTML.
>
> Any idea why?
>
> Regards,
>
>
>
> Fred
>


Because it's returning an empty string - which is NOT the same as null.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  Réponse avec citation
Vieux 31/08/2007, 02h31   #3
Fred Atkinson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Image by Default

On Thu, 30 Aug 2007 00:14:36 -0400, Jerry Stuckle
<jstucklex@attglobal.net> wrote:

>Fred Atkinson wrote:
>> On Tue, 28 Aug 2007 16:17:09 +0100, "peter" <submit@flexiwebhost.com>
>> wrote:
>>
>>>> It returns null, which brings up a blank image.
>>> then you can simply do something such as:-
>>>
>>> <?PHP
>>> $image = getRandomImage('LL/');
>>> if (is_null($image))
>>> {
>>> $image = '';// Set to the image you wish
>>> }
>>> echo "<img src='$image' height=90 width=120 alt='LL'>";
>>> ?>
>>>
>>> in the if statement place the path and name of the image you want to use as
>>> the image that will be displayed if nothing is returned from the function.
>>>

>>
>> When I use this:
>>
>> <?php
>> $image = getRandomImage('LL/');
>> if (is_null($image))
>> {
>> $image = 'none.jpg';// Set to the image you wish
>> }
>> echo "<img src='$image' height=90 width=120 alt='LL'>";
>> ?>
>>
>> and pull up the Web page I look at the source and I see this:
>> <img src='' height=90 width=120 alt='LL'>
>>
>> As you can see the 'none.jpg' default file is not coded into
>> the resulting HTML.
>>
>> Any idea why?
>>
>> Regards,
>>
>>
>>
>> Fred
>>

>
>Because it's returning an empty string - which is NOT the same as null.


As you can see, I am defining the string as none.jpg. I can't
imagine why it still thinks it is null.




Fred

  Réponse avec citation
Vieux 31/08/2007, 02h49   #4
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Image by Default

Fred Atkinson wrote:
> On Thu, 30 Aug 2007 00:14:36 -0400, Jerry Stuckle
> <jstucklex@attglobal.net> wrote:
>
>> Fred Atkinson wrote:
>>> On Tue, 28 Aug 2007 16:17:09 +0100, "peter" <submit@flexiwebhost.com>
>>> wrote:
>>>
>>>>> It returns null, which brings up a blank image.
>>>> then you can simply do something such as:-
>>>>
>>>> <?PHP
>>>> $image = getRandomImage('LL/');
>>>> if (is_null($image))
>>>> {
>>>> $image = '';// Set to the image you wish
>>>> }
>>>> echo "<img src='$image' height=90 width=120 alt='LL'>";
>>>> ?>
>>>>
>>>> in the if statement place the path and name of the image you want to use as
>>>> the image that will be displayed if nothing is returned from the function.
>>>>
>>> When I use this:
>>>
>>> <?php
>>> $image = getRandomImage('LL/');
>>> if (is_null($image))
>>> {
>>> $image = 'none.jpg';// Set to the image you wish
>>> }
>>> echo "<img src='$image' height=90 width=120 alt='LL'>";
>>> ?>
>>>
>>> and pull up the Web page I look at the source and I see this:
>>> <img src='' height=90 width=120 alt='LL'>
>>>
>>> As you can see the 'none.jpg' default file is not coded into
>>> the resulting HTML.
>>>
>>> Any idea why?
>>>
>>> Regards,
>>>
>>>
>>>
>>> Fred
>>>

>> Because it's returning an empty string - which is NOT the same as null.

>
> As you can see, I am defining the string as none.jpg. I can't
> imagine why it still thinks it is null.
>
>
>
>
> Fred
>


Read what I said again.

And no, you're not. You're checking:

if (is_null($image))

And the test is false because it's not null. So you're not setting it
to none.jpg.

It never was null, and PHP doesn't think it's null.

NULL IS NOT THE SAME AS AN EMPTY STRING!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  Réponse avec citation
Vieux 02/09/2007, 16h52   #5
peter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Image by Default


> As you can see, I am defining the string as none.jpg. I can't
> imagine why it still thinks it is null.


As Jerry has pointed out. NULL and an empty string are 2 complete different
things. If the code I supplied is not working then the function is not
returning NULL it is returning an empty string.

That being the case change the is_null function to the empty function

<?PHP
$image = getRandomImage('LL/');
if (empty($image))
{
$image = '';// Set to the image you wish
}
echo "<img src='$image' height=90 width=120 alt='LL'>";
?>


  Réponse avec citation
Vieux 03/09/2007, 02h15   #6
Fred Atkinson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Image by Default

On Sun, 2 Sep 2007 16:52:26 +0100, "peter" <submit@flexiwebhost.com>
wrote:

>
>> As you can see, I am defining the string as none.jpg. I can't
>> imagine why it still thinks it is null.

>
>As Jerry has pointed out. NULL and an empty string are 2 complete different
>things. If the code I supplied is not working then the function is not
>returning NULL it is returning an empty string.
>
>That being the case change the is_null function to the empty function
>
><?PHP
>$image = getRandomImage('LL/');
>if (empty($image))
>{
> $image = '';// Set to the image you wish
>}
>echo "<img src='$image' height=90 width=120 alt='LL'>";
>?>
>


Gentlemen:

I thank you.

Your revision above didn't quite fit my application due to a
quirk in the program being called up (that I didn't show you). But
after I revised it a slight little bit, it did the job just perfectly.
Thank you both for your . I got it working just fine.

My best regards, :-)



Fred Atkinson
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h08.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16249 seconds with 14 queries