I have multiple index.php files in different directories. I've created a script which goes through all of them (around 1000). What I need to do is to replace specific div (by it's class) with php code. The most important thing here is that source code remains unchanged (ON UNCHANGED PARTS).
Related
I want to use a static page for the homepage for faster load times. (In Wordpress)
But after the converting HTML to PHP with an online converter, it failed, I get only a 500 Issue Code and in the source code is nothing.
There's no point of converting your static HTML page to PHP, unless you want to add some content that's frequently updated (for example posts in your blog).
If you want to create a dynamic website, then you should consider writing it in PHP (you can rename your file's extension, no further conversion is required since every line of PHP code is positioned in between <?php and ?> tags). For example: if your page is called index.html, you can simply change its extension to index.php and it will work fine.
BUT! You'll need a server (or a virtual server) to run your PHP scripts (simply opening the PHP file will result in showing HTML and pieces of PHP code instead of executing it).
Why you want to convert HTML to PHP?
The PHP is generally used to generate HTML pages..
And even at the page load level, a PHP page will have to generate the HTML to be output, while an HTML code already written will only need to be read by the server and served to the client.
So I think you read some article about someone who is not very experienced in the industry.. :-)
I want to load all of my content pages off of one (or several depending on media type) php template. For simplicity sake lets just walk through one content type.
As of right now I have all of my content in text files, I plug it into individual divs. Each div is contained within a link that directs to its own php file. This seems extremely redundant and I'd like to cut out these extra php files.
The php template I use is simple and pulls in the text file that I manually plug in with this line of code. file() pulls out every line in target file and stores each line as an index in the array $myContent.
<?php
$myContent = file("contentTxt/006wakeWeRide.txt");
?>
Then I run down the data, and plug it into html accordingly.
The text files have some headers that I pull relevant data from followed by lines that contain the body of the writing.
1: txt //(type)
2: The Wake We Ride //(title)
3: SumOne //(Author)
4: 11/2017 //(date)
5: ./mats/philos.png //(thumbnail)
6: ./content/006wakeWeRide.php //(link to php file)
7..8..: Paragraphs go here //(content)
What I want, is to keep and maintain just the txt files, and to have them all refer to one template. After an hour of research I think I need to implement some sort of a GET request? And somehow pass the text file to load too it. Im not sure how to do this. Linking to the external php is easy. How do I link the user to the page while generating it?
I am beginning to create a pattern library from BareBones. It uses PHP to pull in external HTML files to create the different sections. I would like to be able to have a heading and description for each section. BareBones seems to use a separate text file for the usage descriptions, which I could do for the heading too. This would mean I would have 3 files for each section though. Is there a better way to do this? Some thoughts I had, but haven't been able to figure out are:
Have heading as commented out first line of HTML file and then pull the first line via PHP
Create a variable in the HTML doc somehow and use it to store the heading and call it from the main file. I think to do this I would need to make all of the snippets PHP files though.
Any thoughts?
I have a file structure in place where I'm using SSIs (shtml) to populate pages with images and forward and back links between pages, all the files and links being searched for and populated are variables stored in arrays, echoed to JSON and accessed and utilized in JQuery, called by the HTML.
What I would like to do is have only a single .shtml page and it's accompanying content in one folder for ease of access and edibility, leaving my jquery and PHP in the root directory, so it doesn't have to be copied and pasted to each folder with the html.
The problem is that PHP (right now using a glob function) executes relative to itself and not relative to the html.
So how can I get the glob to look for files relative to the shtml without coming from the root directory? (Because I need everything to stay variable and relative each particular html file.)
I have a file that prints a variable from mysql database via php say it is called independent.php. if we open the file via localhost/independent.php the file displays the information with html.
Is it possible to include independent.php in another php file, and only display the contents generated via php and not the html of independent.php so that using ajax the new html appear?
If you want to use only specific parts of your code, make it modular. Break it down into functions and/or classes. Separate the HTML output from the part that fetches data so you can call both independently. There's no other sane way.