Skip to main content
Inspiring
May 16, 2006
Answered

DW 8 and Partial PHP

  • May 16, 2006
  • 3 replies
  • 336 views
I've setup Apache, PHP 4.3.1, MySQL, and DW 8 on local OS X Panther machine. Everything seemed to work fine:


<?php echo 'Welcome to PHP!';
?> ok

<?php $today = date('F jS, Y');
echo "Today's date is $today";
?> ok

however when I try:

<?php
$taxDue = calculateTax(80, 8);
echo $taxDue; //displays 6.4
?>

I get:

Fatal error: Call to undefined function: calculatetax() in /Users/myComputer/Sites/dw_php/phpFunctionTest.php on line 12

Think this must be a php.ini config problem but I can't locate it. Any help greatly appreciated ...


scootdown



This topic has been closed for replies.
Correct answer scootdown
Ok, forgot to define the function:

<?php
function calculateTax($total, $taxRate) {
$tax = $total * $taxRate/100;
return $tax;
}

$taxDue = calculateTax(80, 8);
echo $taxDue; //displays 6.4
?>

Thanks Joe & Tom!

Scootdown

3 replies

scootdownAuthorCorrect answer
Inspiring
May 16, 2006
Ok, forgot to define the function:

<?php
function calculateTax($total, $taxRate) {
$tax = $total * $taxRate/100;
return $tax;
}

$taxDue = calculateTax(80, 8);
echo $taxDue; //displays 6.4
?>

Thanks Joe & Tom!

Scootdown
Inspiring
May 16, 2006
> Fatal error: Call to undefined function: calculatetax() in
> /Users/myComputer/Sites/dw_php/phpFunctionTest.php on line 12
>
> Think this must be a php.ini config problem but I can't locate it. Any
> help
> greatly appreciated ...

Did you define a calculateTax() function on the page?


--
--
Tom Muck
co-author Dreamweaver MX 2004: The Complete Reference
http://www.tom-muck.com/

Cartweaver Development Team
http://www.cartweaver.com

Extending Knowledge Daily
http://www.communitymx.com/


Inspiring
May 16, 2006
On Tue 16 May 2006 05:45:35p, scootdown wrote in
macromedia.dreamweaver.appdev:

> I've setup Apache, PHP 4.3.1, MySQL, and DW 8 on local OS X Panther
> machine. Everything seemed to work fine:
>
>
> <?php echo 'Welcome to PHP!';
> ?> ok
>
> <?php $today = date('F jS, Y');
> echo "Today's date is $today";
> ?> ok
>
> however when I try:
>
> <?php
> $taxDue = calculateTax(80, 8);
> echo $taxDue; //displays 6.4
> ?>
>
> I get:
>
> Fatal error: Call to undefined function: calculatetax() in
> /Users/myComputer/Sites/dw_php/phpFunctionTest.php on line 12
>
> Think this must be a php.ini config problem but I can't locate it.
> Any help greatly appreciated ...

Did you define calculateTax()? Also, user-defined function names in PHP
are case sensitive:

http://www.php.net/manual/en/language.functions.php#functions.user-defined