[Tfug] PHP Question

George Cohn gwcohn at simplybits.net
Sat Feb 10 20:59:57 MST 2007


I'm trying to write a script in php to download the weather from noaa, 
parse out certain fields and then using the Asterisk Gateway Interface, 
be able to dial an extension and have it give me the current weather.

I have most of it working but I'm stuck on one part.

One example gives this:

if ($currentWindDirection && $currentWindSpeed)
{
fwrite(STDOUT,"STREAM FILE $currentWindDirection \"\"\n");
fflush(STDOUT);

<stuff omitted>

fwrite(STDOUT,"SAY NUMBER $currentWindSpeed \"\"\n");
fflush(STDOUT);
}

What this is supposed to do is take the variables and pass them to the 
AGI so Asterisk can say them, IE: Southwest 11 mph

There's some strings in between that pronounce various words like "the 
wind is from the (variable) at (variable) mph."

Problem is, when I use the && to string them on the same line in the if 
statement, the php script ends at that point.  Everything else runs fine 
up to that point.

I'm not an expert at php, just know enough to be dangerous sometimes.  ;-)

I'm running PHP Version 4.3.10-18 on the Asterisk server that the script 
runs on.

Any quick clues?

George Cohn




More information about the tfug mailing list