Reputation: 1035
I have two php files, one index.php
<?php
include ‘Play.php’;
$temp = first(HH);
echo $temp;
?>
second Play.php
<?php
function first($string)
{
return $string;
}
?>
if i remove $temp = first(HH); from the first file then it works, if i include it, the index.php don't work (don't show anything on the screen when i call it within safari.
I know its going to be obvious but what am i doing wrong? Both files are in the same file directory.
Thanks
Upvotes: 0
Views: 3641
Reputation: 944530
Use the right kind of quotes around your string for the include. "
or '
not ‘
and ’
.
The use of typographic quotes like that suggests you may be trying to write code with a word processor. Don't do that; get a text or code editor instead.
Upvotes: 4
Reputation: 1840
include
expects double quotes "
so change that in, your code and it should work.
include "Play.php";
Upvotes: 1
Reputation: 4275
Your function is right but the way you are calling your function is not correct.And the way you are including the file is incorrect. You should include your file in quotes like ""
or ''
. You have to enclose the string in quotes ""
. Use the code below in index.php
<?php
include 'Play.php';
$temp = first("HH");
echo $temp;
?>
I hope this helps you
Upvotes: 1
Reputation: 3
Kindly change $temp = first(HH); to $temp = first("HH");
its is because your function tack string as a parameter you should send a string
Upvotes: -2