mateic_09 wrote:After that ,I write /opt/lampp/htdocs in the url bar of Chrome and press on the script I want to execute
Actually its exactly what i thought. You are doing a severe error. You MUST NOT enter the local path to your scripts, you MUST enter the fully qualified URL to a webserver. And fully qualified URLs are starting with the protocoll, which is http: in your case, followed by the servername (domain name), which is "localhost" in your case.
Finally, you have to enter
http://localhost/q.php into your browser in order to start your PHP script via your Apache webserver. if you simply enter /opt/lampp/htdocs/q.php, your script is NOT delivered and executed by your Apache server (and the built in PHP interpreter), but solely by your browser, which does not know anything about PHP. Therefore the browser simply downloads the source code, without knowing anything about it.
I recommend reading tutorials about webservers and how things are working, that may help you in understanding how webservers are working.