+ 1
How can i print a php variable in between html tags ?? (not simple)
Hy guyz, i have a php page in which i have declared a variable in a function as function hello(){ $msg = "This is a hello msg": } now i want to show this variable in the bottom of the same page . I am using OOP thats why i cant close and reopen php tags. Tried my best to clarify my problem to you:)
6 Respuestas
+ 1
Insert this code into where you want bro:
<html tag>
<?php echo $msg; ?>
</html tag>
+ 1
Have you tried "echo"?
function hello(){
$msg = "This is a hello msg";
echo $msg;
}
If echo doesn't do it for you:
Usually "OO" in PHP means you're heavily using classes but that is just a function. If you have a larger script, can you paste more?
+ 1
its little bit complex but i will try to clear my point :
//php script
class Loginerror {
function error(){
$msg = "error is : ".mysqli_error();
}
//html page
<input />
<input />
I want to show my variable here when the function is called
<input type="submit" />
+ 1
I want to make an java application.
But i dont know how to code.
Let tell me some idea to code ..
0
function hello(){
$msg = "This is a hello msg";
Return $msg;
}
Echo hello() // call function outside function