/    Sign up×
Community /Pin to ProfileBookmark

PHP Programming

__(Added `[code]…[/code]` tags ~ MOD)__

Fatal error: Uncaught Error: Function name must be a string in C:xampphtdocsLearningPhpindex.php:32 Stack trace: #0 {main} thrown in C:xampphtdocsLearningPhpindex.php on line 32

i get the error above, can any one help me on this ?

my source code are as shown bwlow

[code]
<html>
<head>
<meta charset=”UTF-8″>
<title></title>
</head>
<body>
<?php
// define a class called operation
class operation
{
// defining function add and sub
function add($val1, $val2)
{
$sum = $val1+ $val2;
echo “Sum = “.$sum. “</br>”;
}
function sub ($val1, $val2)
{
$sub = $val1 – $val2;
echo “Defference = “.$sub.”</br>”;
}
}
// craeting object calle solve to access the clas operation
$solve = new operation();
// accessing the methods in class operation
$solve-> add($_GET(‘f’), $_GET(‘s’));
$solve-> sub($_GET(‘f’), $_GET(‘s’));
?>
<form>
enter first value <input type =”text” name =”f”/><hr>
enter second value <input type =”text” name =”s”/><hr>
<input type=”submit” value=”Show result”/>
</form>
</body>
</html>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 04.2020 — $_GET['f'] (array element), not $_GET('f') (function call).
Copy linkTweet thisAlerts:
@gobeseauthorFeb 05.2020 — @NogDog#1614166

Thank you, it worked.
×

Success!

Help @gobese spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...