+ 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:)

21st Jun 2019, 10:33 PM
Maaz Masood
Maaz Masood - avatar
6 Respuestas
+ 1
Insert this code into where you want bro: <html tag> <?php echo $msg; ?> </html tag>
21st Jun 2019, 11:02 PM
Thống Nguyễn
Thống Nguyễn - avatar
+ 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?
21st Jun 2019, 11:06 PM
Josh Greig
Josh Greig - avatar
+ 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" />
21st Jun 2019, 11:21 PM
Maaz Masood
Maaz Masood - avatar
+ 1
I want to make an java application. But i dont know how to code. Let tell me some idea to code ..
25th Jun 2019, 4:50 AM
Bharathi P
Bharathi P - avatar
0
function hello(){ $msg = "This is a hello msg"; Return $msg; } Echo hello() // call function outside function
23rd Jun 2019, 6:57 PM
Shahid Mewafarosh
Shahid Mewafarosh - avatar