Hi all I am trying to call a simple function and I keep getting an error
"Parse error: syntax error, unexpected ';', expecting '{' in C:\wamp\www\david\remoteaccess\index.php on line 15"
This relates to the call and I don't understand why it does not work. I am using WAMP if that makes any difference.

Thanks in advance

David
`

<?php
//session_start();
//include("includes/utilities.php");
//$Errors = "";
//  $_SESSION['LoggedIn'] = false;
//  $_SESSION['UserID'] = "";
//  $_SESSION['UserAdmin'] = false;

function hello() {
    print "<h1>HELLO!</h1>";
    print "<p>Welcome to my web site</p>";
}


function hello();
?>

`

Recommended Answers

All 4 Replies

This might help:

<?php
//session_start();
//include("includes/utilities.php");
//$Errors = "";
//  $_SESSION['LoggedIn'] = false;
//  $_SESSION['UserID'] = "";
//  $_SESSION['UserAdmin'] = false;
$func = function hello() {
    print "<h1>HELLO!</h1>";
    print "<p>Welcome to my web site</p>";
}
echo $func
?>

This relates to the call and I don't understand why it does not work.

To call the function, you need to omit function. That's only used when defining the function.

<?php

function hello() {
    print "<h1>HELLO!</h1>";
    print "<p>Welcome to my web site</p>";
}


hello();
?>

Thanks Pritaeas, a long weekend

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.