How can i add .php file in a .html file? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can i add .php file in a .html file?

13th Jan 2017, 6:27 PM
lefteris13s
lefteris13s - avatar
11 Answers
+ 2
<?php include 'file.php' ?> or <?php require 'file.php' ?> if program will not found file - the second structure throws an error
13th Jan 2017, 6:32 PM
Dmytro-Andrii Kostelny
+ 1
<?php include 'file.php'; ?> or <?php require 'file.php'; ?> Sorry, semicolon is required
13th Jan 2017, 6:43 PM
Dmytro-Andrii Kostelny
+ 1
Try on PC. And don't forget to write some code in this file) You need an Apache server with PHP module)))
13th Jan 2017, 7:13 PM
Dmytro-Andrii Kostelny
+ 1
one file save like .php (what you want to include), and the second like .html. If problem doesn't dissapear, try to change some settings in server
13th Jan 2017, 7:17 PM
Dmytro-Andrii Kostelny
+ 1
Save them to server's root directory or /www folder
13th Jan 2017, 7:19 PM
Dmytro-Andrii Kostelny
+ 1
I haven't expierence with xampp, but maybe you can find it in folder with this server or see this in settings of server. At least in Apache it's C:\apache\localhost\
13th Jan 2017, 7:25 PM
Dmytro-Andrii Kostelny
+ 1
Ok ๐Ÿ˜‚ i just forgot to install xampp or phpMyAdmin, i started Apache from cmd, so I don't know to work with this soft๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚
13th Jan 2017, 7:33 PM
Dmytro-Andrii Kostelny
0
It doesn't work
13th Jan 2017, 6:39 PM
lefteris13s
lefteris13s - avatar
0
again nothing happend
13th Jan 2017, 7:11 PM
lefteris13s
lefteris13s - avatar
0
yeah i am on pc and i run xampp.The php and html files where i have to save them?
13th Jan 2017, 7:14 PM
lefteris13s
lefteris13s - avatar
0
how can i find server's root directory?
13th Jan 2017, 7:22 PM
lefteris13s
lefteris13s - avatar