Jump to content

Function name must be a string Error


dink87522

Recommended Posts

Hi, I'm new to PHP and am having trouble with the following code. Error "

Fatal error: Function name must be a string in C:\xampp\htdocs\stringsWork.php on line 12"

 

strings.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>String Manipulation</title>
</head>

<body>
<textarea name="text" rows="10" columns="125"></textarea>
<p>
<form methord="post" action="stringsWork.php">
<input type="radio" name="fcn" value="strlen" /> Find the text length <br />
<input type="radio" name="fcn" value="strrev" /> Reverse the text <br />
<input type="radio" name="fcn" value="strtoupper" /> Make the text uppercase <br />
<input type="radio" name="fcn" value="strtolower" /> Make the text lowercase <br />
<input type="radio" name="fcn" value="ucwords" /> Capitalize the first letter of each word <br />
<p>
<input type="submit" value = "manipulate the text!" />
</form>
</body>
</html>

 

stringsWork.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>String Manipulation</title>
</head>

<body>
<textarea name="text" rows="10" columns="125"></textarea>
<p>
<form methord="post" action="stringsWork.php">
<input type="radio" name="fcn" value="strlen" /> Find the text length <br />
<input type="radio" name="fcn" value="strrev" /> Reverse the text <br />
<input type="radio" name="fcn" value="strtoupper" /> Make the text uppercase <br />
<input type="radio" name="fcn" value="strtolower" /> Make the text lowercase <br />
<input type="radio" name="fcn" value="ucwords" /> Capitalize the first letter of each word <br />
<p>
<input type="submit" value = "manipulate the text!" />
</form>
</body>
</html>

 

It must be something simple, I'm just not seeing it.

Link to comment
https://forums.phpfreaks.com/topic/163124-function-name-must-be-a-string-error/
Share on other sites

Sorry i posted the wrong one lol.

 

stringsWork.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php $fcn = $_POST['fcn'];
//echo("fcn: $fcn");
$text = $_POST['text'];
//$modifiedText = ($fcn($text));
echo( fcn($text )); ?>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.