php-general Digest 26 Sep 2003 08:49:58 -0000 Issue 2319

Topics (messages 163988 through 164018):

Re: Understanding code.. again
        163988 by: Jeff McKeon
        163989 by: R'twick Niceorgaw
        163990 by: Chris Sherwood
        163991 by: Brad Pauly
        163993 by: Jeff McKeon

Re: PHP Editor - which to use?
        163992 by: Jim Lucas
        163994 by: Jim Lucas
        164004 by: Roger B.A. Klorese

Re: What to use?
        163995 by: Tyler Lane
        163996 by: Jeff McKeon
        163997 by: Robert Cummings
        163998 by: CPT John W. Holmes
        163999 by: CPT John W. Holmes
        164000 by: Eugene Lee
        164003 by: Robert Cummings
        164005 by: Ryan A

Re: mysql.sock file location
        164001 by: Donald Tyler

Broken pipe: core_output_filter: writing data to the network
        164002 by: Martin Greco

Checking mail with `mail`
        164006 by: Dan Phiffer

Re: Help! the Error_Reporting doesn't work
        164007 by: Curt Zirzow
        164016 by: LuckyEagle
        164017 by: Greg Beaver

Re: One variable not equal to 2 values.
        164008 by: Curt Zirzow
        164009 by: Robert Cummings

Private Mail System?
        164010 by: Lee Herron QCS
        164015 by: Ryan Thompson

Re: Timezones and Daylight Savings Time
        164011 by: Tom Rogers

Weird replacing
        164012 by: Anguz Web Design

Form Passed Multidimension Array
        164013 by: Keith Spiller
        164014 by: Robert Cummings

Re: Help understanding code...
        164018 by: Baroiller Pierre-Emmanuel

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 ---
Ok, so if an argument is supplied to the function, the "= null" is
ignored?

Jeff
> -----Original Message-----
> From: Brad Pauly [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, September 25, 2003 4:09 PM
> To: Jeff McKeon
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Understanding code.. again
> 
> 
> Jeff McKeon wrote:
> > Function Showmessage($msgvar = null)
> > {
> >     echo $msgvar;
> > }
> > ?>
> > --snip--
> > 
> > What is the purpose in the function def of "($msgvar = 
> null)"??  Why 
> > not just "function showmessage($msgvar)"??
> 
> That sets a default value for $msgvar so you can call the function 
> without an argument and it will not raise an error.
> 
> - Brad
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message --- Jeff McKeon said the following on 9/25/2003 4:00 PM>>

In the following code...

--snip--
<?PHP
$name = "bob";
Showmessage("hello $name");
Exit;
Function Showmessage($msgvar = null)
{
        echo $msgvar;
}
?>
--snip--

What is the purpose in the function def of "($msgvar = null)"??  Why not
just "function showmessage($msgvar)"??


It's to set a default value if no argument is passed to the function when called like


Showmessage();

In this case $msgvar inside the function will have a null value.

HTH
R'twick

--- End Message ---
--- Begin Message ---
Yes the null is ignored when a var is passed

<-- SNIP-->
Ok, so if an argument is supplied to the function, the "= null" is
ignored?

Jeff
<-- snip --> 

chris

--- End Message ---
--- Begin Message --- Jeff McKeon wrote:

Ok, so if an argument is supplied to the function, the "= null" is
ignored?

Yep.


- Brad
--- End Message ---
--- Begin Message ---
Thanks all!

Jeff 

> -----Original Message-----
> From: Chris Sherwood [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, September 25, 2003 4:15 PM
> To: Jeff McKeon; [EMAIL PROTECTED]
> Subject: Re: [PHP] Understanding code.. again
> 
> 
> Yes the null is ignored when a var is passed
> 
> <-- SNIP-->
> Ok, so if an argument is supplied to the function, the "= 
> null" is ignored?
> 
> Jeff
> <-- snip --> 
> 
> chris
> 
> 

--- End Message ---
--- Begin Message ---
Something else entirely.

I guess you could call them helper scripts libraries.

Example would be: You can program a script to create a switch statement and
then have it prompt you for the number of case statements to add in and if
you want them to break; or not.

Things like that.  Short cuts if you will..

Jim Lucas

----- Original Message ----- 
From: "Roger B.A. Klorese" <[EMAIL PROTECTED]>
To: "'Jim Lucas'" <[EMAIL PROTECTED]>; "'Chris W. Parker'"
<[EMAIL PROTECTED]>; "'jeffrey pearson'" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Thursday, September 25, 2003 12:00 PM
Subject: RE: RE: [PHP] PHP Editor - which to use?


> > you can create so-called assistants...
> >
> > You can create a loop that asks in a table how many rows and
> > columns do you
> > want in that table.
> >
> > Then you can have it create the table with all your favorite
> > default table
> > settings, but while it is generating it, you could have it
> > prompt you for
> > any additional settings that you would like to have in the new table.
>
> That doesn't explain what "internal scripting" is.
>
> Do you mean that edit sessions are scriptable, using its own script
> interpreter?
>
> Or do you mean something else entirely?
>
>

--- End Message ---
--- Begin Message ---
Sorry, someone else responded to your email with the request.

Jim Lucas
----- Original Message ----- 
From: "Chris W. Parker" <[EMAIL PROTECTED]>
To: "Jim Lucas" <[EMAIL PROTECTED]>; "jeffrey pearson"
<[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, September 25, 2003 12:01 PM
Subject: RE: RE: [PHP] PHP Editor - which to use?


Jim Lucas <mailto:[EMAIL PROTECTED]>
    on Thursday, September 25, 2003 11:52 AM said:

> I already answered that question two days ago.

I didn't ask you to answer it twice so I don't what you're talking
about.



c,

--- End Message ---
--- Begin Message ---
> I guess you could call them helper scripts libraries.
> 
> Example would be: You can program a script to create a switch 
> statement and
> then have it prompt you for the number of case statements to 
> add in and if
> you want them to break; or not.
> 
> Things like that.  Short cuts if you will..

Well, if those scripts are taking input and telling the editor what to do,
they're exactly what I said: a scripting language within the editor.

--- End Message ---
--- Begin Message ---
round()
and number_format() are what i would suggest using.

On Thu, 2003-09-25 at 13:01, Ryan A wrote:
> Hi,
> I am running a query on the database to get the avg of a few fields, I am
> getting a result something like this:
> 
> 5.0000
> 4.0000
> 5.0000
> 
> I dont want to use such big averages and want to cut the last to digits off
> so it will be something like:
> 5.00
> 4.00
> 44.23
> etc
> 
> I visited the manual and had a look at a few functions like trim,
> rtrim,ltrim,chop,explode etc....which one is right for me? most of them are
> dealing with whitespace so it does not make much sense right now with my
> current output....
> 
> Please help.
> 
> Thanks,
> -Ryan
> 
> 
> 
> 
> We will slaughter you all! - The Iraqi (Dis)information ministers site
> http://MrSahaf.com
-- 
Tyler Lane <[EMAIL PROTECTED]>
Lyrical Communications

--- End Message ---
--- Begin Message ---
Correct me if I'm wrong please, but I think number_format() has the
adverse effect of changing the value type from numeric to char and
therefore baring you from using it in mathematical equation later in the
script.

Anyway that's what it seemed to do to me when I used it on results from
a MySQL query...

Jeff

> -----Original Message-----
> From: Tyler Lane [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, September 25, 2003 4:20 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] What to use?
> 
> 
> round()
> and number_format() are what i would suggest using.
> 
> On Thu, 2003-09-25 at 13:01, Ryan A wrote:
> > Hi,
> > I am running a query on the database to get the avg of a 
> few fields, I 
> > am getting a result something like this:
> > 
> > 5.0000
> > 4.0000
> > 5.0000
> > 
> > I dont want to use such big averages and want to cut the last to 
> > digits off so it will be something like: 5.00
> > 4.00
> > 44.23
> > etc
> > 
> > I visited the manual and had a look at a few functions like trim, 
> > rtrim,ltrim,chop,explode etc....which one is right for me? most of 
> > them are dealing with whitespace so it does not make much 
> sense right 
> > now with my current output....
> > 
> > Please help.
> > 
> > Thanks,
> > -Ryan
> > 
> > 
> > 
> > 
> > We will slaughter you all! - The Iraqi (Dis)information 
> ministers site 
> > http://MrSahaf.com
> -- 
> Tyler Lane <[EMAIL PROTECTED]>
> Lyrical Communications
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
On Thu, 2003-09-25 at 16:28, Jeff McKeon wrote:
> Correct me if I'm wrong please, but I think number_format() has the
> adverse effect of changing the value type from numeric to char and
> therefore baring you from using it in mathematical equation later in the
> script.
> 
> Anyway that's what it seemed to do to me when I used it on results from
> a MySQL query...

That shouldn't happen. PHP is a typeless language and so type
conversions are juggled on the fly. If you pass a numerical string to a
mathematical operator, then the string will be converted to the
appropriate value.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
From: "Robert Cummings" <[EMAIL PROTECTED]>

> On Thu, 2003-09-25 at 16:28, Jeff McKeon wrote:
> > Correct me if I'm wrong please, but I think number_format() has the
> > adverse effect of changing the value type from numeric to char and
> > therefore baring you from using it in mathematical equation later in the
> > script.
> >
> > Anyway that's what it seemed to do to me when I used it on results from
> > a MySQL query...
>
> That shouldn't happen. PHP is a typeless language and so type
> conversions are juggled on the fly. If you pass a numerical string to a
> mathematical operator, then the string will be converted to the
> appropriate value.

If you get a result of "1,234.56" from number_format() and try to use that
as a numerical value (i.e. it's converted to an int or float), you'll end up
with the value being 1, though. Everything after the first non-numeric
character is lost. That's what he's talking about.

---John Holmes...

--- End Message ---
--- Begin Message ---
From: "Jeff McKeon" <[EMAIL PROTECTED]>

> Correct me if I'm wrong please, but I think number_format() has the
> adverse effect of changing the value type from numeric to char and
> therefore baring you from using it in mathematical equation later in the
> script.

You're correct (kind of). The _result_ of number_format() is a string, but
it doesn't change the original number (unless you're assigning it back to
itself). Even if you are, that's why you use it after you've done all of
your math calculations and only when you're ready to display the number.

If it's really an issue, you can alwasy use printf() or sprintf() to solve
this problem, too.

---John Holmes...

--- End Message ---
--- Begin Message ---
On Thu, Sep 25, 2003 at 10:01:48PM +0200, Ryan A wrote:
: 
: I am running a query on the database to get the avg of a few fields, I am
: getting a result something like this:
: 
: 5.0000
: 4.0000
: 5.0000
: 
: I dont want to use such big averages and want to cut the last to digits off
: so it will be something like:
: 5.00
: 4.00
: 44.23
: etc

Why not keep the precision internally and only deal with it as an output
formatting issue when you display the results?

        $a = 5.0000;
        printf("\$a = %.2f \n", $a);

--- End Message ---
--- Begin Message ---
*slaps self* Yep, forgot about that part of number format :)

Rob.


On Thu, 2003-09-25 at 16:51, CPT John W. Holmes wrote:
> From: "Robert Cummings" <[EMAIL PROTECTED]>
> 
> > On Thu, 2003-09-25 at 16:28, Jeff McKeon wrote:
> > > Correct me if I'm wrong please, but I think number_format() has the
> > > adverse effect of changing the value type from numeric to char and
> > > therefore baring you from using it in mathematical equation later in the
> > > script.
> > >
> > > Anyway that's what it seemed to do to me when I used it on results from
> > > a MySQL query...
> >
> > That shouldn't happen. PHP is a typeless language and so type
> > conversions are juggled on the fly. If you pass a numerical string to a
> > mathematical operator, then the string will be converted to the
> > appropriate value.
> 
> If you get a result of "1,234.56" from number_format() and try to use that
> as a numerical value (i.e. it's converted to an int or float), you'll end up
> with the value being 1, though. Everything after the first non-numeric
> character is lost. That's what he's talking about.
> 
> ---John Holmes...
> 
> 
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Hey,
If anyones intrested, solved the problem like this:

********************************
function cun($num)
{
$num = number_format($num,2,'.',',');
return $num;
}

echo cun($var1);
********************************

Cheers,
-Ryan


We will slaughter you all! - The Iraqi (Dis)information ministers site
http://MrSahaf.com

--- End Message ---
--- Begin Message ---
Well after getting MySQL back up and running (After restarting the
machine) the script worked fine. So it looks like editing the PHP.ini
file worked.

Thanks to everyone who helped. Don't know where I would be without you
guys (& gals?).

Donald.

-----Original Message-----
From: Jay Blanchard [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 25, 2003 10:40 AM
To: Donald Tyler; [EMAIL PROTECTED]
Subject: RE: [PHP] mysql.sock file location

[snip]
I wasn't worried about short code =0P

I would have done this if I was:

        $Connection = mysql_connect('localhost','******','******')
                or die(mysql_error());

=0P
[/snip]

Cool, but do you get errors?

--- End Message ---
--- Begin Message ---
Hi.
I have a Redhat 8 box with Apache 2.0.40, PHP 4.3.1, FreeTDS 0.61 working
MS-SQL2000 server.

When surfing any application sometimes when i hit a link or button the
application dies (it does not load anything, the crash is instantaneous) and
it shows this in the apache logs:

[Mon Sep 22 14:00:25 2003] [info] (32)Broken pipe: core_output_filter:
writing data to the network.

have no more data about this. I don't know if it is a Apache or PHP problem.

Any thoughts?

Thanks

-- 
###################
# Martin Greco

--- End Message ---
--- Begin Message ---
Is it practical to check for new mail from PHP using the UNIX mail utility?
This would mainly be used to check for bounces from large mailings. Bonus
points for anyone who can find me an article explaining the technique.

Thanks!
-Dan

--- End Message ---
--- Begin Message ---
* Thus wrote Raquel Rice ([EMAIL PROTECTED]):
> On Thu, 25 Sep 2003 08:32:03 -0500
> "Shawn McKenzie" <[EMAIL PROTECTED]> wrote:
> 
> > "Luckyeagle" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > I have set the PHP.INI as follow:
> > >
> > > error_reporting = E_ALL & ~E_NOTICE
> > > display_errors = On
> > > display_startup_errors = Off
> > > log_errors = On
> > > log_errors_max_len = 1024
> > > ignore_repeated_errors = Off
> > > ignore_repeated_source = Off
> > > report_memleaks = On
> > > track_errors = Off
> > >
> > > But it doesn't work
> > > How can i solve it?
> > >
> > > Thanks a lot
> > 
> > What do you mean "it doesn't work"?  It doesn't display errors? 
> > How do you know that you have errors?  Are you running your own
> > script or someone else's?
> > 
> > -Shawn
> > 
> 
> AND ... where is the logfile indicated?  Does the script have access
> (read/write) to the logfile?  
> 

AND.. is php even using that file your modifying?


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
I write some PHP files including some errors
When it runs on another server,it will display "notice",but on my
computer,it won't.
"Luckyeagle" <[EMAIL PROTECTED]> дÈëÓʼþ
news:[EMAIL PROTECTED]
> I have set the PHP.INI as follow:
>
> error_reporting = E_ALL & ~E_NOTICE
> display_errors = On
> display_startup_errors = Off
> log_errors = On
> log_errors_max_len = 1024
> ignore_repeated_errors = Off
> ignore_repeated_source = Off
> report_memleaks = On
> track_errors = Off
>
> But it doesn't work
> How can i solve it?
>
> Thanks a lot

--- End Message ---
--- Begin Message --- Um,

E_ALL & ~E_NOTICE

disables notices.

Try

E_ALL

Greg

Luckyeagle wrote:

I write some PHP files including some errors
When it runs on another server,it will display "notice",but on my
computer,it won't.
"Luckyeagle" <[EMAIL PROTECTED]> дÈëÓʼþ
news:[EMAIL PROTECTED]

I have set the PHP.INI as follow:

error_reporting = E_ALL & ~E_NOTICE
display_errors = On
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off

But it doesn't work
How can i solve it?

Thanks a lot

--- End Message ---
--- Begin Message ---
* Thus wrote Ed Curtis ([EMAIL PROTECTED]):
> 
>  How would I write this statement:
> 
> if $thisvar is not equal to this value or that value. { do stuff }
> 

Ok. I have to throw this in for historical purposes :)

switch ($thisvar) {
  case 'thisvalue':
  case 'thatvalue':
    break;
  default:
    // do stuff
    break;
}



Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
On Thu, 2003-09-25 at 19:49, Curt Zirzow wrote:
> * Thus wrote Ed Curtis ([EMAIL PROTECTED]):
> > 
> >  How would I write this statement:
> > 
> > if $thisvar is not equal to this value or that value. { do stuff }
> > 
> 
> Ok. I have to throw this in for historical purposes :)
> 
> switch ($thisvar) {
>   case 'thisvalue':
>   case 'thatvalue':
>     break;
>   default:
>     // do stuff
>     break;
> }

*grin* here's another:

if( $thisvar == 'this value'
        ? false
        : ($thisvar == 'that value'
            ? false
            : true) )
{
    // do stuff.
}

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Anyone know of a private mail system, like say vbb has built-in, but stand
alone? No, not interested in pop3 or smtp interfacing, simply a web based
private mail system with nothing else.

--- End Message ---
--- Begin Message ---
I would think you're asking on the wrong list. Try find a list for software
or servers.

Lee Herron QCS wrote:

Anyone know of a private mail system, like say vbb has built-in, but stand
alone? No, not interested in pop3 or smtp interfacing, simply a web based
private mail system with nothing else.




-- Ryan Thompson [EMAIL PROTECTED] http://osgw.sourceforge.net

--- End Message ---
--- Begin Message ---
Hi,

Friday, September 26, 2003, 2:55:51 AM, you wrote:
JJ> Got a client site in Thailand that is about 13 hours
JJ> different from the Web Server time so with any
JJ> date/time stamping I need to add the 13 hours. 
JJ> However, when it comes time for DST, I'd hate to have
JJ> to code for that or remember to manually change the
JJ> time stamping.

JJ> Is there some kind of automated function that
JJ> determines the time zone of one location to another
JJ> and stamps the correct time -- with or without DST?


JJ> I guess otherwise you'd have to do something like:
if >> Oct 31st and < April XX { time+12 } else {
JJ> time+13

JJ> Obviously not the correct code but that's the idea. 
JJ> Am I off base here?  Is there a simpler method or
JJ> something I'm not thinking of?

JJ> If the server was dedicated I would just fix the
JJ> server time to be Thailand time, but it's a shared
JJ> server and I can't do that.

JJ> Thanks in advance!


JJ> __________________________________
JJ> Do you Yahoo!?
JJ> The New Yahoo! Shopping - with improved product search
JJ> http://shopping.yahoo.com


You could put this at the top of each page

putenv('TZ=Asia/Bangkok');

That will correct all PHP functions, not sure about database times though
-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
Hi,

I wrote a code to change the urls in my forum, to a new format. I
did it with output buffering and inside it, I used
preg_replace_callback, which worked great for me. But I shared
this code with the forum program community and there's a person
that can't make it work. He says his Apache gets caught up in a
loop or something. So I looked for an alternative to
preg_replace_callback. The way I did it is with preg_match_all
and then changed each element in the array and saved the changed
elements in a new array, then I just str_replace using the arrays
as find/replace. This solutions worked fine, almost. I use two
functions to do changes to the urls, one to make them relative
and the other to change symbols in the query, to something more
friendly to search-engine spiders. The function to make them
relative works great with the new method, as it did with
preg_replace_callback, but the other function, the one to replace
symbols in the query, is acting in an odd way.

Here's function

<?php
   function spider_url($match){
      if(!strstr($match['2'], 'action') || strstr($match['2'],
'display') || strstr($match['2'], 'messageindex'))
         return $match['1'] . '/' . str_replace(array("=", ";",
"&"), array("-", "_", "_"), $match['2']);
      return $match['0'];
   }
?>

if I call it with this

<?php
   /// $scripturl is the var that has the url to the forum
script, like http://example.com/bbs/index.php
   $buffer = preg_replace_callback('/(' . preg_quote($scripturl,
'/') . ')\?([\w;=~&+%]+)/i', 'spider_url', $buffer);
?>

it works great and the url

http://example.com/bbs/index.php?board=1;action=display;thread=12
3;start=1

changes to

http://example.com/bbs/index.php/board-1_action-display_thread-12
3_start-1

but if I do it with this

<?php
   preg_match_all('/(' . preg_quote($scripturl, '/') .
')\?([\w;=~&+%]+)/i', $buffer, $match_spider, PREG_SET_ORDER);
   for($i = 0; $i < count($match_spider); $i++){
      $arr1_spider[$i] = $match_spider[$i]['0'];
      $arr2_spider[$i] = spider_url($match_spider[$i]);
   }
   $buffer = str_replace($arr1_spider, $arr2_spider, $buffer);
?>

then the url comes out like this

http://example.com/bbs/index.php/board-1;action=display;thread=12
3;start=1

It changes just the first part, up to the semicolon... I did
other tests and there was one where changed everything up to the
semicolon right before 'star'....

I can't understand what's going on, so if someone has a clue,
please tell me. Thank you very much in advance for taking your
time reading this.

Cristian

--- End Message ---
--- Begin Message ---
Hello,

I am trying to find out how to pass a multidimensional array within a hidden input of 
a form.
Would it be something like this?

  <input type='hidden' name='all_links' value='$all_links'>

Any advice would be forever appreciated...


Keith

--- End Message ---
--- Begin Message ---
On Thu, 2003-09-25 at 22:33, Keith Spiller wrote:
> Hello,
> 
> I am trying to find out how to pass a multidimensional array within a hidden input 
> of a form.
> Would it be something like this?
> 
>   <input type='hidden' name='all_links' value='$all_links'>
> 
> Any advice would be forever appreciated...

The following might work:

echo '<input type="hidden"'
    .' name="all_links"'
    .' value="'.htmlentities( serialize( $all_links ) ).'" />';

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Hi,
It's a "C Like Syntax"

(condition)?true:false;

is like :

if (condition)  true
else false

regards.
P.E. Baroiller

"Jeff McKeon" <[EMAIL PROTECTED]> a écrit dans le message de
news:[EMAIL PROTECTED]
I've just picked up a more advanced book on PHP and it has a lot of
example code in it. I understand most of it but some things I'm seeing I
don't understand. Like the following...

code:
------------------------------------------------------------------------
--------

$couponcode = (! empty($_REQUEST['couponcode'])) ?
$_REQUEST['couponcode'] : NULL;
------------------------------------------------------------------------
--------

I think this is saying:

If the global variable couponcode is not empty, then the variable
'$couponcode' is equal to "$_REQUEST['couponcode']" otherwise it gets a
"NULL" value.

What's throwing me is the use of the "!" and "?" and ":"

If What I suspect is correct, I've never seen an if-then statement like
this. If it is a replacement for an IF-Then statement then it's much
cleaner and I'd like to use it.

another one is:


code:
------------------------------------------------------------------------
--------
IF (!strcmp($operator, '+')) {
$result = $num1 + $num2
}
------------------------------------------------------------------------
--------

I've looked up strcmp() and know it's used to compair two strings. The
$operator variable in the script that this was taken from is set to
either "-", "+", "*" or "/". What I don't understand here is what the
"!" in front of strcmp() means.

Can anyone break down the code for me and explain the parts?

thanks,

Jeff

--- End Message ---

Reply via email to