November 23, 20205 yr 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
February 19, 20215 yr Community Expert 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.
February 19, 20215 yr 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
February 20, 20215 yr 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
Archived
This topic is now archived and is closed to further replies.