JealousMaiden Posted November 23, 2020 Share Posted November 23, 2020 Hey guys! I'm currently learning to setup and develop some basic websites with the basics i've learned at University. I already have swag up and running on my Unraid Server. I was able to get a website running with some basic HTML and JS and access it over DNS, but now i want to use some PHP. I have no clue, how to use PHP with swag and found absolutely nothing about it on the internet. I've tried to just implement some PHP code in the standard index.html in the www/ folder, but it doesn't do anything at all. I would appreciate any help. Thanks in advance! JM Quote Link to comment
amac Posted February 19, 2021 Share Posted February 19, 2021 Having the same issue. PHP just shows up as a comment in my HTML Quote Link to comment
itimpi Posted February 19, 2021 Share Posted February 19, 2021 PHP runs server side so is run before the page is sent to the browser. It is widely used to populate/generate many of the pages in the web GUI. What are you actually trying to use PHP to do? Knowing that might mean you get some pointers. 1 Quote Link to comment
Squid Posted February 19, 2021 Share Posted February 19, 2021 On 11/23/2020 at 12:55 PM, JealousMaiden said: I've tried to just implement some PHP code in the standard index.html in the www/ folder, but it doesn't do anything at all. PHP incorporated into an HTML file always runs prior to the page being loaded. ie: ... <?PHP var $test = "This is a test"; ?> <script> $("#element").html("<?=$test?>"); </script> Will result in the javascript sent to the browser being $("#element").html("This is a test"); Are you trying to make the PHP dynamically affect the page? In this case, you need to use appropriate post / get / ajax calls 1 Quote Link to comment
amac Posted February 20, 2021 Share Posted February 20, 2021 Hi all. Was making a noob mistake. I had a .html extension on my index file instead of .php. I changed it to "index.php" and it works now. thanks Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.