Webstorm doesn't debug .php files in Chrome - php

When I click "debugging"
in Firefox I get the result page in html, that I can inspect:
But in Chrome I just get PHP source code:
What is the problem?
Has anyone come across?

You're accessing the file directly on disk. Try accessing it through your webserver (in other words, serve the page as HTML).

Related

Passing a file into browser using header() php

Is it possible using the header() function or perhaps another php function to pass a file to the browser locally?
I am currently using Chrome. I have the Office Editing for Docs extension installed which essentially allows me to open Word docx files locally into my Chrome browser by passing the full directory and file name into the URL address bar of Chrome. This essentially opens the Word file in Chrome. I would like to accomplish this task in php
I have tried the following below but no luck.
header( 'Location: file://c:\users\jbloggs\desktop\test.docx' );
I know the header() function is primarily used for redirecting to a web page
header( 'Location: http://www.google.com' );
Any help much appreciated.
It doesn't work this way, because you are trying to redirect from a remote server to a local file path. Chrome doesn't accept this because of security considerations. Note that it doesn't matter whether your web server is running on the same physical machine, it is seen as a separate server from your local file system. You can however accomplish this task using normal HTML:
Document
If you save this to a static HTML file and open it in your browser you should upon click be redirected to the document. If you want a direct redirect, use JavaScripts window.location You cannot however serve the file from a HTTP Server, like mentioned above.
If you want to do so, you have to serve the .docx file from your server as well, by including it as static content and then linking to it via HTTP as well.
Hope this helps!

Notepad++ php load error page

I have made a custom theme with wordpress locally with wamp.I use notepad++ for writing my code.Some days before when I wanted to load my page from notepad I had to go to run->launch in Firefox and had no problem showing the page where in the address bar the URL was:localhost/wordpress.
Now when I try to load my php files from notepad (run ->launch in Firefox) it shows a corrupt html page not all of it ,with some rules of php and without CSS and no images.In the address bar when running my project from notepad the URL is file:///C:/wamp/www/wordpress/wp-content/themes/revenant/page-about-us.php which is incorect ofcourse.Also it does not understand the php code.For example the title for about us page is
<?php echo get_the_title('about-us'); ?>
But when I write manually in the address bar the URL of my project like localhost/wordpress everythng shows as they shown before with no problem.I have not changed any settings in notepad.Why this problem came up with no reason?Why it doesnot load php and css? Thank you!
Notepad++ doesn't know that you have a webserver running or what the document root is, so it cannot take you to the file's URL. When it opens the file in the browser, it is loading the file directly off the hard drive (hence the file://). It is not being served by the webserver that knows how to parse PHP, it is being read directly by the browser, which does not.

Breaking up a PHP webpage

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.

php code turned gibberish?

I went to edit this PHP file - it's supposed to generate those captcha security images on contact forms - the images werent working, so I was going to see if there was a broken path or something i could fix simply.
But when I opened the file it looked like this:
http://mydomainsample.com/explosion/screenshots/Screen%20Shot%202012-05-17%20at%209.34.14%20AM.png
complete gibberish.
Is it possible this happened somehow while downloading the file from the server? I did not have ftp access to the site originally - we got control of the domain and transferred it from one host to another.
I used site sucker to backup the site before transferring, but it downloads php files as html files. you end up with filename.php.html.
in the past this has never turned the php into incomprehensible gibberish, so i dont understand why it did now.
The problem is, you cannot use programs like "site sucker" to get PHP files. This is because when you get a PHP file from a URL, the file is executed, and you're getting the output of the script. That's why you get .php.html.
It doesn't "turn the php into incomprehensible gibberish", the server runs the script and you're getting the output. Most of the time the output is HTML, which you can open as text. In this case, the script's output is a PNG file, thus why you see "gibberish". Rename the file to .png, then you'll see the image.
You need to get FTP access in order to get the PHP source.
That's a PNG image, not PHP source code.
The file actually looks like a PNG image, maybe you just downloaded output the PHP script has generated?

CSS and Javascript not working! Browser cannot read css and javascript files

I'm using a CMS called 'Nukeviet' and I installed it on my localhost. I'm facing a very strange problem, I've tried to search for the solution but nothing found.
I can see that css files are not working at all. When I use Firebug to find the problem, I switch to the tab 'CSS' and... all the required css files are there but it says... there're no rules! When I use the Developer tools of Google Chrome, in Resources tab, Chrome can see all the css files, but the contents of them are abnormal, like in this image:
.
I checked the encoding but it's normally ANSI. And, of course, the contents in all the css files are normal ANSI, no international text.
I tried copying the css files to a new place and write a new HTML for testing, those CSS works perfectly as usual without any problem.
So I can't understand why there're "ugly" question marks like that. Something... encrypted it?
Javascript files get the exact same problem, but image files are ok, all the others are ok, just problem with CSS and Javascript.
I think your javascript and css files are compressed for example with gzip-compression ...
Please check the configuration of your webserver if the gzip-comression is enabled.
If you're using Apache this can also be done in the .htaccess-files instead of the server-configuration - but I think that's stuff you know - don't you?
For further information:
http://developer.yahoo.com/performance/rules.html#gzip
At this page you can also check if some header-informations are missing in the response you get from your server if you request the css-file.

Categories