Is there a way to see the included code by "included" or "require_once" in the same file without open the included file? Sometimes I would like to have all the final code in the same page..
I usually use vscode, but if there is a way with another tool i can give it a try.
Thanks
Adobe Dreamweaver has this capability: you can simply press Ctrl+D while cursor is on "include" or "require" and included file will open in the new tab. Very convinient. I have also searched for anything similar for VS Code, but sadly couldn't find anything. Adobe Dreamweaver is not free like VS Code though.
Related
Is there a way with PHP or even IIS 7.5 to see exactly what files were accessed/loaded to render a page? For example, if a PHP page has 5 includes in it, I want to see exactly what those include files were.
Reason I'm asking is because I'm trying to fix a hacked site and I believe the hacked file is living outside of the website's files, but somewhere else on the server. I'vehad zero luck finding it and I'm hoping that if I can see exactly what files are being loaded/accessed when a page loads then that will help me track down where the problem is. Thanks!
The web server wouldn't have anything to do with PHP includes but PHP includes a function called get_included_files.
At the end of your script, you could put:
var_dump(get_included_files());
Of course, a file doesn't have to be "included" to have executable code. A file could be read and executed with eval() so you may consider disabling eval() if you don't use it anywhere.
register_shutdown_function (function () {
print_r(get_included_files());
});
This should tell you as soon as the script ends which files were used during execution. I suggest dumping the result to a file.
I am having issues while running the live preview of some php files on LOCALHOST. Like I am working on Wordpress theme and while I am able to set the correct base URL and open the file on the browser through index.php, but I am not able to edit and view the other php files.
For example, I have to open index.php which is in http://localhost/test but suppose I want to edit the header.php file. I click on the header.php file and it opens a new page in Browser with URL, http://localhost/test/header.php, which returns a 404 error through wordpress(OOPS PAGE NOT FOUND!)
I have very little work with index.php and mostly with header, footer, functions and everything else. Although this isn't really a big issue, I can go with the traditional way but I really wanted to utilize this Brackets Feature. Hope there's something to get past this :)
This is not an issue this will never open in browser like single file, if you want to check this then header.php and footer.php files are also included into the index.php , you will check from that no need to run them to browser.
I'm not sure if I did anything to cause this, but when I opened up Eclipse, it would only let me view and edit HTML, CSS, and JavaScript files. If I try to open a PHP file, a blank window opens where you would normally view the file. The window has no content or title, just the "X" to close it. Anyone have any ideas what would cause this?
In case it matters, I'm using Version: Luna Release (4.4.0)
Build id: 20140612-0600
So I've created a php webpage with a head section that links to some bootstrap css files and my custom css file. This webpage also has a foot division that links to the necessary jQuery and bootstrap JavaScript files. That's all fine and dandy: I know it works because when I launch this .php in firefox, I can see that Bootstrap has taken control and stylized the text. The problem occurs when I try to break this webpage up into components...
I've created a separate head.html and foot.html which include the same content as before they were broken up, and on the .php page I use the following include statements:
<?php include '../components/head.html'; ?>
<?php include '../components/foot.html'; ?>
Now when I launch the php from my browser, the links clearly haven't worked because the text is not styled. Upon choosing to "view source" of the .php, I see that it has not included the markup from head.html or foot.html, and instead I still see the literal <?php include '';> statements. What have I done wrong? I know the relative filepaths are correct, so perhaps it has something to do with the fact I'm trying to launch the php page locally? Perhaps the components should be .php instead of .html? I really don't know.
Additional info: Win7, tried using notepad++ because Dreamweaver keeps giving me FTP errors every time I ask to "preview in browser"
First you should have a webserver installed along with PHP. You may use xampp or wampp. If you simply open a php file in your browser then it will not execute the PHP statements instead will display the code as it is.
Except for not having a web server along with PHP installed in your system you have done nothing wrong as I see.
The head.html and foot.html can be html files and not .php files that would not be an issue till the file containing the include statment is .php file.
I want to use some php to make simple header/footer files for my webpages. I'm just getting started in web design and I am using Coffee Cup HTML Editor.
Problem is I have this line in my index.php file:
?php include(“includes/header.html”);?>
and nothing shows up even though my header.html file has a menu in it.
Do I need to install something on my machine before PHP code will show anything?
Syntax errors
Firstly, your code snippet contains a syntax error. The opening PHP tag should be <?php and not ?php. So your code should look like this:
<?php include('includes/header.html');?>
Install PHP
Secondly, you need to run PHP scripts on a PHP server like XAMPP for the code to actually be executed.
This assumes header.html either contains text or if it is PHP it echo()s its output.