I have some php code that says if index.php or main root then display some code and if not then show other code and it works on index.php but if it’s just the domain name without index.php at the end, it don’t work. I have the following code at the moment
Can anyone help me out please as I don’t know what to amend for the code to work if main root and not have index.php at the end, the code should be the same for the main root / and index.php
I would suggest using something like Visual Studio Code to debug your code. You can step through what each variable contains. I think you can attach your PHP executable to VS Code to do that. Much easier than just sitting there and guessing.
Yes, you’d use either echo or var_dump() to show the value of a variable at a particular point in the code, perhaps with an exit() afterwards if there are issues with seeing the output on a crowded screen.
var_dump() is probably the better option, as it will work on any data type, not just strings. That will cover you for the unexpected, which is often what you get when de-bugging.
Also keep in mind the URI carries any and all query parameters along with it, and in certain invocation contexts will also carry the scheme/domain information.