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.)
Related
How do i get the directory structure and filenames under a PHP website I do not own?. Not the code, just the structure and the filenames.?
I tried httrack, but since it's a PHP website, it doesn't work.
You won't be able to extract the complete structure of a PHP website without having access to the server. You can maybe find out from where it pulls images and scripts by looking at src attributes of script and img tags as well as analysing the href attribute of a tags.
If you do find links containing strings like wp-includes or wp-content you can guess that it is a WordPress site for example which pretty much has a fixed structure.
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).
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 have maybe ten .php files that make up the main pages of my website and 20 .css files all in all. I noticed that when I made a submit button in one file, it adopted the attributes of a .css file that I had not linked through the normal html way.
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
However, I have referenced other .php files like this:
include('config.php');
And then in config I referenced many other files in some kind of tangled web.
Does that mean that css is passed on through the PHP include method - and that in multiple layers? e.g. if I referenced a file in config.php that didn't directly reference a css file, but instead another php file which maybe DID directly reference css.
I have to apologize if this is a slightly confused question, it's just my mind cannot comprehend this... CSSCeption...
Consider this... If you go to your site and right click the page and click view source. You will see your entire document, including any items that might be included.
Think of it in this way. An include, is a sort of way of saying, at this position in the document, there should be other things. It looks for the file you include and takes it's contents, whatever that is, and sticks those contents where the include is, it will do this with every include until it finally reaches the end of the document.
In this way, it brings in HTML that has your CSS files linked, and then it reads the HTML that it just brought in, and it applies those CSS files styles to the entirety of the document after all of the HTML has been loaded.
First of all you must know that CSS doesn't "know" what php means, CSS defines HOW HTML elements are to be displayed. So it will take place after the web server converts all your php code into html.
I have an application using Jquery's UI Tabs for an overall menu, and they're great. However, I've come to a strategy question when implementing the new format.
First, the concept:
An index.php file includes several class files (also PHP) and calls the tabs
Each tab pulls in one file per page via the script's "ajax loading" feature (As described here)
Each tab's page contains a combination of static text, content loaded server-side at display, and content that's dynamically updated via jQuery's Ajax.
Now, the challenge:
Everything is working as expected except that pages that are pulled into the tabs don't have access to the aforementioned included php files on the index page. I'm able to use that content if I do a separate includes on each of the ajax included pages, but that could get out of hand in a hurry. So, I'm seeking a strategy to get one set of included files to persist across all my pages.
Any ideas for a graceful solution to this challenge?
PHP (well, the entire web) is stateless, meaning once the PHP interpreter has parsed a file, it spits it out and is done with it. There is no way for it to persist includes parsed in one instance to another instance.
The only way for the pages to gain access to files included in the "main" page is to include those files themselves. Like you said though, that could get out of hand and be pain-staking to maintain, which is why a lot of people resort to a registry file. Your registry file loads the includes you need, and you only need to include the registry file on all of your pages.