Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have downloaded a several nulled website templates for testing purposes.
I was wondering if I could combine them into one webpage?
For example, take category page layout from one webpage and implement it to other webpage. Is it possible to create webpage using php and html files combined, lets say index.html and contact.php?
Thank You in advance.
YES, you can. But, it's fairly not easy though.
When you are combining two different templates, each have seperate stylesheets and possible Javascript/JQuery scripts, which conflicts between the two.
And you can combine php and html files in same file.
Just use <?php at the beginning of php code and ?> at the end of php code.
Hope this helps. :)
Yes, it's just a matter of copying the section of code from one file and pasting it in the other. Which is why templates are available in the first place. But notice that you can't go copying PHP code and placubgit in a .html file.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
How do we write files that are included in a php webpage using includes or requires.
(1)Is there any programming convention for the stuff?
For example: Do you add title in the header/footer file or not? if yes won't there be two titles one from the file included and one of the file that is including the footer/header file. What about bootstrap/js files do I include them in header/footer file or not? Because header/footer contain the usage of bootstrap classes.Won't importing them again and again increase the loading time of pages? (2)So basically do we add head section? if yes how do these values affect the current document?
As I am just beginner I would be glad if you could share some example that has html and php code in the file that gets included. Along with bit of explanation regarding the questions above (1&2). Thank you.
Instead of asking about includes or requires for rendering conventions I would suggest you learn how does a "Render Engine" works. For example Twig (from Symfony), Blade (from Laravel) or Mustache.
Basically, because you should want to distinguish between the different layers in your system. The rendering layer should not contain any other logic but rendering.
The easiest approach here, especially if you're new, is to go with the MVC (Model-View-Controller). And from there you can escalate the structure.
The answer for this question "Adding header or footer in php" is basically Twig or Blade.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I apologize for asking such a beginner question, but i'm unsure on where else I could go to get such help. I'm currently creating a php website using GoggleApp Engine. I've created a very simple form using html in the same file as my PHP. Now, I know this isn't good practice, so I want to break up my html into it's own file. My only question is, how would I re-write this code assuming that my html is in it's own file?
It is perfectly fine to place your PHP code in the same file as your HTML code. However, if you are going to duplicate code, it would be best to have separate files (maybe say a header and footer file).
That way you can use require_once("header.php") and require_once("footer.php") in each file that wants to use the top and bottom portions of your code.
As Sven mentioned, you can look into templating. You can also look into coding habits such as MVC (Model View Controller) and similar methods.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working on a PHP website, and don't want to have to write headers, footers, etc. for every page. I came up with the idea to have written headers and footers that could be retrieved with a function just like Wordpress. I found Wordpress's get_header(); function in /wp-includes/general-template.php but it loads through a template which I do not have being a hand written website. My question is "How do I write multiple PHP files such as header.php, and footer.php, etc. and compile them in to one document in the index.php?
Look into the include() function, along with the similar include_once(), require(), and require_once().
A. Make sure your index page is index.php and not index.html.
B. Write one header file, header.php, and use if/else statements to bring in the content you want for that particular page.
C. Use <?php include('header.php'); ?>at the top of your index.php and <?php include('footer.php'); ?> at the bottom of your page.
D. If this isn't working, make sure your server has PHP installed on it.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I know CSS and HTML to a reasonable degree, but I've never built a multi-page website before.
I have a header area of my site coded, and want it to display it across multiple webpages. How can I do this?
Save it as header.php/header.html whichever one you need. Then, from every file you code from then on, you can <?php include('header.php');?>. The files you include in HAVE to be .php or it wont work.
Same applies to jsp if for any reason php didnt work or you fancied a change of pace
Create a file called header.jsp then use the tag below when you want to include it on a page.
<jsp:include page="{header.jsp}"/>
This is maybe of no use to you but who knows it may help someone. Some people find this easier and some find this harder it depends on your programming background.
Use a web programming language (PHP / ASP.Net / Whatever you like) to include the navigation bar in all the pages. There are template languages like Twig that can do that for you in a smarter way and provide you with additional template features, if you might need them.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Our site is linking to php files containing javascript, so the javascript can use php to get data from the database. Here's an example of how these files are linked:
<script type="text/javascript" src="http://www.our-site.com/javascript.php"></script>
My question is what is this called? I've tried using google to help me with coding issues, but it's hard when you don't know what to search for.
Server-side-generated JavaScript would be an appropriate description. It even shows up on Google autocomplete, and there are many results. I am not a fan of this pattern. I find that it is better to keep JavaScript on the view-side completely and just inject the values you need via an init method of some sort.
It doesn't have a special name when it's PHP.
Just make sure you set the header in the PHP file.
Header("content-type: application/x-javascript");
What you have there is nothing special. It's not named somehow. You just include the PHP file, the PHP file gets interpreted and generates any kind of output which then gets included as regular JavaScript.
If you have issues you might just open up the link to the PHP file and search for your problem there.