php-general Digest 26 Oct 2007 14:12:38 -0000 Issue 5093
Topics (messages 263681 through 263710):
Re: Slashes, include, AJAX?
263681 by: Nathan Nobbe
263686 by: Rodrigo Poblanno Balp
263706 by: Nathan Nobbe
Re: SMTP unable to relay
263682 by: Wolf
Re: SMTP
263683 by: Wolf
Re: Maximum function nesting level of '100' reached
263684 by: Larry Garfield
263698 by: Jochem Maas
263699 by: Paul Scott
263703 by: Jochem Maas
263708 by: T.Lensselink
263710 by: Jochem Maas
Re: show required row first and then other remaining rows
263685 by: Sanjeev N
returning an array from a function?
263687 by: info.phpyellow.com
263688 by: Simon Welsh
Pspell needed for Googiespell?
263689 by: Merlin
263690 by: Merlin
Fatal error when calling nested function
263691 by: Kefaleas Stavros
263692 by: Edward Kay
263693 by: Kefaleas Stavros
263694 by: Kefaleas Stavros
263695 by: Edward Kay
cant send mail
263696 by: Diana
263697 by: Stut
Question
263700 by: arash moosavi
263701 by: Dan Shirah
263702 by: Zoltán Németh
Re: Executing PHP
263704 by: Philip Thompson
263709 by: Stut
e-mail code
263705 by: arash moosavi
263707 by: Jochem Maas
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 ---
On 10/25/07, Rodrigo Poblanno Balp <[EMAIL PROTECTED]> wrote:
>
> Nathan Nobbe wrote:
>
> On 10/25/07, Rodrigo Poblanno Balp <[EMAIL PROTECTED]> wrote:
> >
> > Hi everybody!
> >
> > I'm building a small ajax app which consists of only 3 php files.
> >
> > index.php which contains all the app and has a couple of links. When a
> > link is clicked an Ajax request is sent to the server (using prototype)
> > to the
> > url central.php with only one parameter 'id'. Depending on that
> > parameter, central.php should look for the appropiate content, in this
> > case link1.php.
> > Then I return a JSON object with the "things" that should be updated on
> > index.php
> >
> > So this is the pseudo-code:
> >
> > index.php
> > <html>...
> > <body>
> > <a href="" onclick="[send the Ajax request using prototype with the id =
> > 1]>Link #1</a>
> > <div id="theUpdatableDIV"></div>
> > </body>
> >
> >
> > central.php
> > <html>...
> > <body>
> > <?php
> > [read the id parameter]
> > switch(id){
> > case 1: //which is the only case for now!!
> > //build the JSON object
> > $output = array("title" => "Link #1 Title!",
> > "content"=>file_get_contents("link1.php"));//here I read the last file
> > which has the content to be updated asynchronously
> > return [the JSON object based on $output];
> > break;
> > }
> > ?>
> > </body>
> >
> > link1.php
> > <div>Welcome to the content of link #1 which was updated using <a
> > href=" ajax.org">ajax</a></div>
> >
> > the JSON object is formed ok, now, my problem is that link1.php outputs
> > like this:
> >
> > <div>Welcome to the content of link #1 which was updated using <a
> > href="ajax.org">ajax<\/a><\/div>
> >
> > So at the moment I update the <div id="theUpdatableDIV"> element on
> > index.php, I get no "real" content, but a string with the
> > strange slashes.
> >
> > I've tried:
> > stripslashes, ereg_replace, str_replace and strtr to eliminate the
> > wierd slashes.
> >
> > Can anybody tell how to do it right?
>
>
> how are you building the json object?
>
> i recommend
> json_encode(utf8_encode($dataToEncode));
>
> if youre using php5. if youre using php4, try this:
> http://mike.teczno.com/JSON/JSON.phps
>
> also, you might want to check out firebug for firefox. it will let you
> easily analyze the interaction between the client and server.
>
> also, to verify that the json object youre generating is infact ok;
> run it through here:
> http://www.jslint.com/
>
> -nathan
>
> Hi Nathan,
>
> I'm using php5, and I'm building the JSON object just like that, with the
> json_encode.
> The problem with using utf_encode apart from the original is that I get
> the \n\r for each line in the file read.
> Any suggestions?
>
> Thanx
>
are you running windows?
im guessing those are newline characters in windows format that arent
getting interpreted correctly on the
client side. you might try stripping out the newline characters prior to
encoding the data.
$jsonOut = json_encode(utf8_encode(str_replace("\r\n", '',
$stringToEncode)));
also, what are you trying to encode? if you are encoding arrays or objects
(php that is) you will have to
utf8_encode all the elements of those complex datums prior to handing them
to json_encode() for
the final output.
-nathan
--- End Message ---
--- Begin Message ---
Nathan Nobbe wrote:
On 10/25/07, *Rodrigo Poblanno Balp* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Nathan Nobbe wrote:
On 10/25/07, *Rodrigo Poblanno Balp* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hi everybody!
I'm building a small ajax app which consists of only 3 php files.
index.php which contains all the app and has a couple of
links. When a
link is clicked an Ajax request is sent to the server (using
prototype)
to the
url central.php with only one parameter 'id'. Depending on that
parameter, central.php should look for the appropiate
content, in this
case link1.php.
Then I return a JSON object with the "things" that should be
updated on
index.php
So this is the pseudo-code:
index.php
<html>...
<body>
<a href="" onclick="[send the Ajax request using prototype
with the id =
1]>Link #1</a>
<div id="theUpdatableDIV"></div>
</body>
central.php
<html>...
<body>
<?php
[read the id parameter]
switch(id){
case 1: //which is the only case for now!!
//build the JSON object
$output = array("title" => "Link #1 Title!",
"content"=>file_get_contents("link1.php"));//here I read the
last file
which has the content to be updated asynchronously
return [the JSON object based on $output];
break;
}
?>
</body>
link1.php
<div>Welcome to the content of link #1 which was updated using <a
href=" ajax.org <http://ajax.org>">ajax</a></div>
the JSON object is formed ok, now, my problem is that
link1.php outputs
like this:
<div>Welcome to the content of link #1 which was updated
using <a
href="ajax.org <http://ajax.org>">ajax<\/a><\/div>
So at the moment I update the <div id="theUpdatableDIV">
element on
index.php, I get no "real" content, but a string with the
strange slashes.
I've tried:
stripslashes, ereg_replace, str_replace and strtr to
eliminate the
wierd slashes.
Can anybody tell how to do it right?
how are you building the json object?
i recommend
json_encode(utf8_encode($dataToEncode));
if youre using php5. if youre using php4, try this:
http://mike.teczno.com/JSON/JSON.phps
also, you might want to check out firebug for firefox. it will
let you
easily analyze the interaction between the client and server.
also, to verify that the json object youre generating is infact ok;
run it through here:
http://www.jslint.com/
-nathan
Hi Nathan,
I'm using php5, and I'm building the JSON object just like that,
with the json_encode.
The problem with using utf_encode apart from the original is that
I get the \n\r for each line in the file read.
Any suggestions?
Thanx
are you running windows?
im guessing those are newline characters in windows format that arent
getting interpreted correctly on the
client side. you might try stripping out the newline characters prior
to encoding the data.
$jsonOut = json_encode(utf8_encode(str_replace("\r\n", '',
$stringToEncode)));
also, what are you trying to encode? if you are encoding arrays or
objects (php that is) you will have to
utf8_encode all the elements of those complex datums prior to handing
them to json_encode() for
the final output.
-nathan
Hi again Nathan,
well I actually did that before, using the str_replace to eliminate al
the windows \r\n, but the big problem isn't that
the HTML code is being escaped too.
I get something like <div>this is the content<\/div>
it seems like the '/' is being escaped, but I need it as HTML.
Balpo
--- End Message ---
--- Begin Message ---
On 10/26/07, Rodrigo Poblanno Balp <[EMAIL PROTECTED]> wrote:
>
> I get something like <div>this is the content<\/div>
> it seems like the '/' is being escaped, but I need it as HTML.
>
how are you using the json object on the client-side after its sent by the
server?
below is a json snippet from an application of mine, many of the tags look
the same
as what youve shown (because theyve been encoded the same way).
ive have not encountered the problem you have, that is, the escape
characters do
not pass though when i splice them into the DOM.
im using the same encoding technique i recommended within PHP. on the
client side
i instantiate the json object as follows:
var htmlUpdates = eval("(" + transport.responseText + ")");
if you use a string directly on the client side, the escape characters will
pass
through, however, if you run it through eval(), the escape characters will
be stipped
out by the javascript interpreter. im not sure whats going on, but im
starting to think
its something on the client side..
-nathan
{"prevUpperNavId":"0:0","nextUpperNavId":"1:1","breadcrumb":"","leftContent":"<p>\nPHP
is very interesting
. One of it's greatest strengths is the gradient of
development\npossibilities. A new PHP writer can
easily publish their first dynamic page in a matter\nof minutes.
Using PHP's integrated templating
system, PHP scripts can be escaped at any time.\nSo escaping them
simply outputs anything text directly
as it appears in the script. By adding\nscript tags into large pages
of code and dropping in PHP function
calls, dynamic pages are easily\nobtained.<br\/>\n<br\/>\nAlthough
handy, this isnt often the greatest
technique for developing highly reusable or readable code.\nPHP
offers many options for templating HTML
. This is just the beginning. As a PHP developer, you will\nfind
yourself needing to know a lot of
technologies.\n<\/p>","rightContent":"<div>\n<p>\n\tHere is a small
list of terms and acronyms one might
encounter working with PHP;\n\thow many do you
recognize?\n<\/p>\n\t<ul>\n\t\t<li>\n\t\t\tObject Oriented
Programming\n\t\t<\/li>\n\t\t<li>\n\t\t\tDesign
Patterns\n\t\t<\/li>\n\t\t<li>\n\t\t\tMVC\n\t\t<\/li
>\n\t\t<li>\n\t\t\tORM\n\t\t<\/li>\n\t\t<li>\n\t\t\tZend\n\t\t<\/li>\n\t\t<li>\n\t\t\tCMS\n\t\t<\/li
>\n\t\t<li>\n\t\t\tShared
Nothing\n\t\t<\/li>\n\t\t<li>\n\t\t\tAJAX\n\t\t<\/li>\n\t\t<li>\n\t\t\tJSON
\n\t\t<\/li>\n\t\t<li>\n\t\t\tUnit
Test\n\t\t<\/li>\n\t\t<li>\n\t\t\tSOAP\n\t\t<\/li>\n\t<\/ul>\n<\/div
>"}
--- End Message ---
--- Begin Message ---
As previously posted, you need to work with your mail server admin.
sendmail is not normally on WinDoze boxes, so do some googling for the
setup you have, and talk with your admins to see what you need to do to
get it set up to work correctly.
Wolf
Diana wrote:
> I have tried settiing my php.ini to
> SMTP = localhost
> as well as using the SMTP of my regular mail, and I keep on getting this.
> Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to
> relay for [EMAIL PROTECTED] in C:\Inetpub\wwwroot\intranet\test.php
> on line 11
>
--- End Message ---
--- Begin Message ---
As previously posted, you need to work with your mail server admin.
sendmail is not normally on WinDoze boxes, so do some googling for the
setup you have, and talk with your admins to see what you need to do to
get it set up to work correctly.
Wolf
Daniel Brown wrote:
> On 10/25/07, Jens Kleikamp <[EMAIL PROTECTED]> wrote:
>> Diana schrieb:
>>> I dont know what I did but now I get this message Failed to connect to
>>> mailserver at "localhost" port 25, verify your "SMTP"
>>>
>> Do you have a smtp server running on localhost?
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Diana,
>
> Try to keep all of the messages in a single thread so that people
> searching the archives can benefit from your solution as well.
>
> Check into the following:
>
> 1.) Is there an SMTP server running on port 25 on the local machine?
> 2.) Is there a firewall blocking incoming or outgoing connections
> on that port?
> 3.) Is PHP able to connect to any remote SMTP servers, or by domain name?
>
--- End Message ---
--- Begin Message ---
If I had to venture a guess, you nested 100 functions (called 100 functions in
a stack), and therefore reached the maximum limit in PHP. That is, you
overflowed the stack. You may have a recursion problem, especially if you're
using an XML parser that is not the PHP 5-native one.
On Thursday 25 October 2007, Sascha Braun wrote:
> What is the cause for that error:
>
> Fatal error: Maximum function nesting level of '100' reached, aborting!
> in /home/Projekte/spectral/modules/xml_mm/classes/xml_mm.class.php on
> line 118
>
> Thank you!
>
> Sascha
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
--- End Message ---
--- Begin Message ---
Larry Garfield wrote:
> If I had to venture a guess, you nested 100 functions (called 100 functions
> in
> a stack), and therefore reached the maximum limit in PHP. That is, you
> overflowed the stack. You may have a recursion problem, especially if you're
> using an XML parser that is not the PHP 5-native one.
since when is there an arbitrary maximum recursion limit???
>
> On Thursday 25 October 2007, Sascha Braun wrote:
>> What is the cause for that error:
>>
>> Fatal error: Maximum function nesting level of '100' reached, aborting!
>> in /home/Projekte/spectral/modules/xml_mm/classes/xml_mm.class.php on
>> line 118
>>
>> Thank you!
>>
>> Sascha
>
>
--- End Message ---
--- Begin Message ---
On Fri, 2007-10-26 at 12:52 +0200, Jochem Maas wrote:
> since when is there an arbitrary maximum recursion limit???
Since forever... ;)
I thought that it was at 60 though...
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
--- End Message ---
--- Begin Message ---
Paul Scott wrote:
> On Fri, 2007-10-26 at 12:52 +0200, Jochem Maas wrote:
>
>> since when is there an arbitrary maximum recursion limit???
>
> Since forever... ;)
thats you think, personally I test this kind of thing when Im
not sure:
php -r 'function foo() { static $x = 1; echo "foo ", $x++, "\n"; foo(); }
foo();'
which proves quite adequately that there is no function recursion limit as such,
and that the error message is simply 'Segmentation Fault' as opposed to some
message
about recursion limit being reached.
therefore the recursion limit, whether in defined in php source or in user land
code
is something specific to the XML extension/code the OP was using.
>
> I thought that it was at 60 though...
>
> --Paul
>
>
>
> ------------------------------------------------------------------------
>
> All Email originating from UWC is covered by disclaimer
> http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
--- End Message ---
--- Begin Message ---
On Fri, 26 Oct 2007 14:32:42 +0200, Jochem Maas <[EMAIL PROTECTED]>
wrote:
> Paul Scott wrote:
>> On Fri, 2007-10-26 at 12:52 +0200, Jochem Maas wrote:
>>
>>> since when is there an arbitrary maximum recursion limit???
>>
>> Since forever... ;)
>
> thats you think, personally I test this kind of thing when Im
> not sure:
>
> php -r 'function foo() { static $x = 1; echo "foo ", $x++, "\n"; foo(); }
> foo();'
>
> which proves quite adequately that there is no function recursion limit
as
> such,
> and that the error message is simply 'Segmentation Fault' as opposed to
> some message
> about recursion limit being reached.
>
> therefore the recursion limit, whether in defined in php source or in
user
> land code
> is something specific to the XML extension/code the OP was using.
>
>>
>> I thought that it was at 60 though...
>>
>> --Paul
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> All Email originating from UWC is covered by disclaimer
>> http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
Running your code shows that there is a limit. Although it doesn't throw an
error.
It just stops after n recursive calls:
php4 recursive calls: 796
php5 recursive calls: 49841
php6 recursive calls: 6007
--- End Message ---
--- Begin Message ---
T.Lensselink wrote:
>
> On Fri, 26 Oct 2007 14:32:42 +0200, Jochem Maas <[EMAIL PROTECTED]>
> wrote:
>> Paul Scott wrote:
>>> On Fri, 2007-10-26 at 12:52 +0200, Jochem Maas wrote:
>>>
>>>> since when is there an arbitrary maximum recursion limit???
>>> Since forever... ;)
>> thats you think, personally I test this kind of thing when Im
>> not sure:
>>
php -r 'function foo() { static $x = 1; echo "foo ", $x++, "\n"; foo(); }
foo();'
...
>
> Running your code shows that there is a limit. Although it doesn't throw an
> error.
> It just stops after n recursive calls:
>
> php4 recursive calls: 796
> php5 recursive calls: 49841
> php6 recursive calls: 6007
A. this is not the output of the script
B. do you think these numbers are the same for everyone?
heck they're not even garanteed to be the same between 2 runs
on the same machine with the same php binary.
C. it doesn't just stop, a segmentation fault occurs.
e.g.:
last 2 lines of output for 4.3.10-19:
foo 11137
foo Segmentatie fout
last 2 lines of output for 4.3.10-19:
foo 11147
foo Segmentatie fout
last 2 lines of output for 5.1.1:
foo 37435
foo Segmentation fault
last 2 lines of output for 5.1.1:
foo 37436
foo Segmentation fault
last 2 lines of output for 5.1.2:
foo 30795
foo Segmentatie fout
last 2 lines of output for 5.1.2:
foo 30787
foo Segmentatie fout
Therfore there is NO recursion limit in php (not withstanding a specific limit
in functions belonging to an XML extention). the percieved limit is php running
out of memory ... as long as there is memory php will continue to recurse.
--- End Message ---
--- Begin Message ---
Hi Andrew,
Thanks a lot. it really worked very well.
Sanjeev
On 10/26/07, Andrew Ballard <[EMAIL PROTECTED]> wrote:
>
> This should work:
>
> ORDER BY CASE WHEN id = 3 THEN 0 ELSE 1 END, name
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Warm Regards
Sanjeev
------------------------------------------------
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com/ - Website submission
http://webhosting.sanchanworld.com/ - Webhosting solution provider
--- End Message ---
--- Begin Message ---
Hello all,
function convert( $latitude, $longitude ) {
$mve_latitude = $latitude; // actually other processing within this function
determines this
$mve_longitude = $longitude // actually other processing within this function
determines this
$mve_both = $mve_latitude . ", " . $mve_longitude;
// prepare return values
$mve_array[0] = $mve_latitude;
$mve_array[1] = $mve_longitude;
$mve_array[2] = $mve_both;
return $mve_array;
} // function
$latitude = 23.263400;
$longitude = 80.110030
convert( $latitude, $longitude );
print_r( $mve_array );
.. the above does not return a value in the array. What do I have to change to
receive an array with global scope from this function? I read several pages of
docs on php.net but the light didn't go on...
Sincerely,
Rob.
--- End Message ---
--- Begin Message ---
$mve_array = convert( $latitude, $longitude );
or, in convert(), before the first call to $mve_array:
global $mve_array;
On 26/10/2007, at 8:09, [EMAIL PROTECTED] wrote:
Hello all,
function convert( $latitude, $longitude ) {
$mve_latitude = $latitude; // actually other processing within this
function determines this
$mve_longitude = $longitude // actually other processing within
this function determines this
$mve_both = $mve_latitude . ", " . $mve_longitude;
// prepare return values
$mve_array[0] = $mve_latitude;
$mve_array[1] = $mve_longitude;
$mve_array[2] = $mve_both;
return $mve_array;
} // function
$latitude = 23.263400;
$longitude = 80.110030
convert( $latitude, $longitude );
print_r( $mve_array );
.. the above does not return a value in the array. What do I have
to change to receive an array with global scope from this function?
I read several pages of docs on php.net but the light didn't go on...
Sincerely,
Rob.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
Simon Welsh
Admin of http://simon.geek.nz/
Windows is a joke operating system. Hell, it's not even an operating
system. NT is Not Tough enough for me either. 95 is how may times it
will crash an hour.
http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
--- End Message ---
--- Begin Message ---
Hello everybody,
I am trying to get googiespell running but it looks like I
do need PHP5 installed with pspell. Am I right?
The doc's on the site are not clear about this. I am currently running
php 4.x The doc page lists GSpellerServer, but it makes the impression
that this is optional.
http://orangoo.com/labs/GoogieSpell/Documentation/
Has anybody tested this so far?
Best regards,
Merlin
--- End Message ---
--- Begin Message ---
Merlin schrieb:
Hello everybody,
I am trying to get googiespell running but it looks like I
do need PHP5 installed with pspell. Am I right?
The doc's on the site are not clear about this. I am currently running
php 4.x The doc page lists GSpellerServer, but it makes the impression
that this is optional.
http://orangoo.com/labs/GoogieSpell/Documentation/
Has anybody tested this so far?
Best regards,
Merlin
Hi,
just found the problem. PHP has to be compile with ssl. I am using a
workaround with CURL and it works now.
Best regards, Merlin
--- End Message ---
--- Begin Message ---
Here's the list :
<?php
function salestax($price,$tax) {
function convert_pound($dollars, $conversion=1.6) {
return $dollars * $conversion;
}
$total = $price + ($price * $tax);
echo "Total cost in dollars: $total. Cost in British pounds: "
.convert_pound($total);
}
echo convert_pound(15);
?>
I get the following error :
*Fatal error*: Call to undefined function convert_pound() in
...*Untitled-1.php* on line *18
*line 18 is this one : echo convert_pound(15);
--- End Message ---
--- Begin Message ---
> Here's the list :
>
> <?php
> function salestax($price,$tax) {
> function convert_pound($dollars, $conversion=1.6) {
> return $dollars * $conversion;
> }
> $total = $price + ($price * $tax);
> echo "Total cost in dollars: $total. Cost in British pounds: "
> .convert_pound($total);
> }
> echo convert_pound(15);
> ?>
>
> I get the following error :
>
> *Fatal error*: Call to undefined function convert_pound() in
> ...*Untitled-1.php* on line *18
>
> *line 18 is this one : echo convert_pound(15);
>
From
http://www.daaq.net/old/php/index.php?page=php+adv+functions&parent=php+flow
+control:
"When you define a function within another function it does not exist until
the parent function is executed. Once the parent function has been executed,
the nested function is defined and as with any function, accessible from
anywhere within the current document. If you have nested functions in your
code, you can only execute the outer function once. Repeated calls will try
to redeclare the inner functions, which will generate an error."
So, as you're not calling salestax() anywhere, the convert_pound function
isn't defined.
I wasn't aware of nested functions before your question, but reading the
above on how the declaring function can only be called once, I feel they are
best avoided. Does anyone have anyone have any examples where using them
would be beneficial?
E
--- End Message ---
--- Begin Message ---
Edward Kay wrote:
Here's the list :
<?php
function salestax($price,$tax) {
function convert_pound($dollars, $conversion=1.6) {
return $dollars * $conversion;
}
$total = $price + ($price * $tax);
echo "Total cost in dollars: $total. Cost in British pounds: "
.convert_pound($total);
}
echo convert_pound(15);
?>
I get the following error :
*Fatal error*: Call to undefined function convert_pound() in
...*Untitled-1.php* on line *18
*line 18 is this one : echo convert_pound(15);
From
http://www.daaq.net/old/php/index.php?page=php+adv+functions&parent=php+flow
+control:
"When you define a function within another function it does not exist until
the parent function is executed. Once the parent function has been executed,
the nested function is defined and as with any function, accessible from
anywhere within the current document. If you have nested functions in your
code, you can only execute the outer function once. Repeated calls will try
to redeclare the inner functions, which will generate an error."
So, as you're not calling salestax() anywhere, the convert_pound function
isn't defined.
I wasn't aware of nested functions before your question, but reading the
above on how the declaring function can only be called once, I feel they are
best avoided. Does anyone have anyone have any examples where using them
would be beneficial?
E
Ok.If I use the code below :
<?php
function salestax($price,$tax) {
function convert_pound($dollars, $conversion=1.6) {
return $dollars * $conversion;
}
$total = $price + ($price * $tax);
echo "Total cost in dollars: $total. Cost in British pounds: "
.convert_pound($total);
}
salestax(15.00,.075);
echo convert_pound(15);
?>
I get no errors but I still get only the 1st line executed.
--- End Message ---
--- Begin Message ---
Edward Kay wrote:
Here's the list :
<?php
function salestax($price,$tax) {
function convert_pound($dollars, $conversion=1.6) {
return $dollars * $conversion;
}
$total = $price + ($price * $tax);
echo "Total cost in dollars: $total. Cost in British pounds: "
.convert_pound($total);
}
echo convert_pound(15);
?>
I get the following error :
*Fatal error*: Call to undefined function convert_pound() in
...*Untitled-1.php* on line *18
*line 18 is this one : echo convert_pound(15);
From
http://www.daaq.net/old/php/index.php?page=php+adv+functions&parent=php+flow
+control:
"When you define a function within another function it does not exist until
the parent function is executed. Once the parent function has been executed,
the nested function is defined and as with any function, accessible from
anywhere within the current document. If you have nested functions in your
code, you can only execute the outer function once. Repeated calls will try
to redeclare the inner functions, which will generate an error."
So, as you're not calling salestax() anywhere, the convert_pound function
isn't defined.
I wasn't aware of nested functions before your question, but reading the
above on how the declaring function can only be called once, I feel they are
best avoided. Does anyone have anyone have any examples where using them
would be beneficial?
E
Ok.It was simply an oversight from my side.If I put a <br /> I get the
two results clearly.Here is the clearer code :
<?php
function salestax($price,$tax) {
function convert_pound($dollars, $conversion=1.6) {
return $dollars * $conversion;
}
$total = $price + ($price * $tax);
echo "Total cost in dollars: $total. Cost in British pounds: "
.convert_pound($total);
}
salestax(15.00,.075);
echo "<br />" . convert_pound(15);
?>
--- End Message ---
--- Begin Message ---
>
> <?php
> function salestax($price,$tax) {
> function convert_pound($dollars, $conversion=1.6) {
> return $dollars * $conversion;
> }
> $total = $price + ($price * $tax);
> echo "Total cost in dollars: $total. Cost in British pounds: "
> .convert_pound($total);
> }
> salestax(15.00,.075);
> echo "<br />" . convert_pound(15);
> ?>
>
That's still pretty nasty though:
<?php
<snip>
salestax(15.00,.075);
salestax(15.00,.075);
?>
gives:
Total cost in dollars: 16.125. Cost in British pounds: 25.8
24
Fatal error: Cannot redeclare convert_pound() ...
What's wrong with non-nested functions? i.e.:
function convert_pound($dollars, $conversion=1.6) {
return $dollars * $conversion;
}
function salestax($price,$tax) {
$total = $price + ($price * $tax);
echo "Total cost in dollars: $total. Cost in British pounds: "
.convert_pound($total);
}
E
--- End Message ---
--- Begin Message ---
The problem is I am the mail server administrator also. This is a small
company of 4 .
--
Diana Castillo
Tsanalytics S.A.
Tel: 34 913 595 436
Fax: 34 913 595 439
Mov: 34 609 954 536
[EMAIL PROTECTED]
www.tsanalytics.com
--- End Message ---
--- Begin Message ---
Please include the list when replying.
[EMAIL PROTECTED] wrote:
The problem is I am the mail server administrator also. This is a small
company of 4 .
That may be so, but this is a PHP mailing list. I don't mean to sound
harsh, but if you need help configuring a mail server this is not the
place to find it.
-Stut
--
http://stut.net/
----- Original Message ----- From: "Stut" <[EMAIL PROTECTED]>
To: "Diana" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, October 26, 2007 1:48 AM
Subject: Re: [PHP] cant send mail
Diana wrote:
Using windows XP, when I try to send mail using 4 parameters, I get
this :
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1
Unable to
relay for [EMAIL PROTECTED] in
C:\Inetpub\wwwroot\intranet\test.php
on line 9
The SMTP server you are using is not configured to allow the machine
you're running PHP on to send mail. This is not a PHP problem - speak
to your mail server administrator.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
I have Question In PHP Where Can I send it to Give my answer?
--- End Message ---
--- Begin Message ---
This is a PHP users mailing list. If you have a question, you can send it
to [EMAIL PROTECTED] and whoever can help you with it will reply.
On 10/26/07, arash moosavi <[EMAIL PROTECTED]> wrote:
>
> I have Question In PHP Where Can I send it to Give my answer?
>
--- End Message ---
--- Begin Message ---
2007. 10. 26, péntek keltezéssel 15.26-kor arash moosavi ezt írta:
> I have Question In PHP Where Can I send it to Give my answer?
for example to this list ;)
(it's not sure you will get the exact answer you want, but the chances
are pretty good)
greets
Zoltán Németh
--- End Message ---
--- Begin Message ---
On 10/25/07, Stut <[EMAIL PROTECTED]> wrote:
>
> Philip Thompson wrote:
> > Hi. Feel free to tell me this is a "duh" question. I don't know which
> PHP
> > executable (php.exe, php-cgi.exe, php-win.exe) is being run - how can I
> > tell?
> >
> > I am on a Win2k3 server running PHP5 (manual install) and IIS6. I've
> pointed
> > to the php5isapi.dll in IIS. I'm assuming b/c I do this that I am using
> the
> > php.exe. Thoughts? I've searched the PHP manual, but have had no luck.
>
> You're not running any exe file. IIS uses php5isapi.dll instead of an
> exe file - they essentially do the same job but the dll is designed to
> be loaded into another application.
>
> -Stut
This is wonderful to know! Is this documented in the PHP manual (if so,
where), or are you just brilliant? =D
Thanks!
~Philip
--- End Message ---
--- Begin Message ---
Philip Thompson wrote:
On 10/25/07, Stut <[EMAIL PROTECTED]> wrote:
Philip Thompson wrote:
Hi. Feel free to tell me this is a "duh" question. I don't know which
PHP
executable (php.exe, php-cgi.exe, php-win.exe) is being run - how can I
tell?
I am on a Win2k3 server running PHP5 (manual install) and IIS6. I've
pointed
to the php5isapi.dll in IIS. I'm assuming b/c I do this that I am using
the
php.exe. Thoughts? I've searched the PHP manual, but have had no luck.
You're not running any exe file. IIS uses php5isapi.dll instead of an
exe file - they essentially do the same job but the dll is designed to
be loaded into another application.
-Stut
This is wonderful to know! Is this documented in the PHP manual (if so,
where), or are you just brilliant? =D
I don't know if this is detailed in the manual - I just know a bit about
how Windows and PHP work.
As for my brilliance, I'm not qualified to comment.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
First: how can I write php code that alert me when I have new mail?
such as Gmail
Second:Where can I find "libgmailer" sample code?
for example reading new mail or sending mail and more..
Thank You
--- End Message ---
--- Begin Message ---
arash moosavi wrote:
> First: how can I write php code that alert me when I have new mail?
> such as Gmail
first you read lots about php and programming, whilst your doing that
you you try out lots of code to see what it does ... eventually your
understanding gets to a level where you are capable of writing some code
to do something you want.
easy really.
this mailing list is not here to turn whatever idea you happen
to have today into working code.
>
> Second:Where can I find "libgmailer" sample code?
google for "libgmailer"
> for example reading new mail or sending mail and more..
>
> Thank You
>
--- End Message ---