Is it possible to view the output of a PHP script in the Run Tool Window as rendered HTML?
I have an application that generates HTML output and currently I need to copy it from the console, save it in an HTML file and open that file in a browser to view the rendered output.
Eclipse PDT has a view called "Web Browser", for instance.
Unfortunately no -- PhpStorm (and any other IDE built on IDEA platform AFAIK) does not have such functionality.
You may submit Feature Request ticket to their Issue Tracker .. but I doubt that it will be implemented any time soon (very limited usage case, as far as I see it right now).
I may suggest to save such output into .html file directly (if you can edit such script -- at least during your debug/test sessions) and open it in browser (then simple "Refresh" in browser will do the job).
If you are executing the PHP file in the console and then manually copying the html code and saving it to a file and finally running it, running this command might help :
php file.php | cat > file.html | google_chrome file.html
Or maybe you can just do :
php file.php | cat > file.html
and refresh the page in the browser.
In this case you won't have to manually copy the code each time.
Related
Can anyone tell here, what is the command to run html with php script. Normally in my linux terminal, if i want to run html, my command is
firefox <filename>.html
It works fine and display output in firefox browser. But some how, when I add php script, the browser doesn't show the output from php script. It show source code. I try the answer from the forum below, it doesn't work for me.
Using .htaccess to make all .html pages to run as .php files?
How to run a php script inside a html file?
So here, i want to ask
1) What is the step to run html with php script
2) what is the command to run?
3) The source code, need to save in .html or .php ?
Is there any way to run php in browser without using apache?
Rename file.html to file.php and check.
I think you write PHP and HTML in a single document, and you use only html extension.
You can't run php codes without install PHP package on your OS. your browser can't understand your php code without this package, So your browser show source code.
After that you can run php file as a page or put it into a html page by iframe html tag.
I have a strange setup at the moment (busy with a migration)
I have a 4th Dimension application which calls php scripts (which is our soon to be, only application. Dropping 4D)
This script thats called from 4D needs to open a html file in the browser.
Is this possible?
Iv'e tried something along the lines of
header('Location: ./DischargeLetter.php?id='.urlencode($id));
This passes the html document (report) that I want to open along with the patient id.
calling it in the browser works (obviously hey), but how can I get php to open the browser or a tab and head to that page?
From what I understand you have a command line script in php and you are trying to open a browser on the server?
If you are using the php like a command scripting language you can use http://php.net/manual/en/function.shell-exec.php to call other commands so you can call something like
shell_exec('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe $url');
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.
I'm a frontend developer and I'm facing with a problem.
Whenever I'm building a website, I'm using PHP to include the template files, so I get a redundant code.
But when I want to generate this file into an HTML file I open up the PHP file in the browser to copy/paste the code to an HTML file.
How can I make this process to be way much faster, or how could I avoid to do these things manually? Maybe there is a program to do this or something?
You can use a recursive wget.
Say your webserver runs on your localhost, you can run:
wget -r -k localhost
Be careful: wgetdoes not perform a search on which pages are available, it simply looks at links (the <a> tags) and will capture these as well. As long as everything is reachable from the index page (not necessarily on the index page), it will be downloaded.
wget is a linux program, but I guess there is a Windows application with the same name/options as well... As #rkbvkleef points out, it's part of the MinGW package.
Basically your php file (which runs on server, could be local server) contains or generates your HTML code to present on browser. You can simply write HTML code out of tags in a php file and it will work. Or if you want to generate some HTML based on some conditions you are checking inside php or using some variables in php then you can use echo function. It will display whatever string you echo on your webpage.
<?php
$name = "Murtaza";
echo("<h1>Hello ".$name."</h1>");
?>
I wrote some PHP to generate a single PDF file with multiple pages based on input from a Comma Seperated Values (.csv) file.
Someone who is not familiar with programming will be running the PHP very often to generate the PDF file. That person will be responsible for changing the CSV file before generating it.
I need to know how I can provide him/her a shortcut in Windows so that when he/she click it, the PHP should execute and produce the PDF file in a hardcoded path.
You can create an shortcut on file itself, or executive php bin. Check Command Line PHP on Microsoft Windows.
Just create shortcut with C:\PHP5\php.exe -f "C:\PHP Scripts\script.php" -- -arg1 -arg2 -arg3, but it will be depended on locations. So you could create association with php files and just create shortcut to your script.
Or you could launch web-server (php web-server) and put link to your script to favorites in browser.
Just create a shortcut to the page, e.g.
http://www.example.com/mypdf.php
You can even open the link with a specific browser by typing one of these as the shortcut location:
chrome http://www.example.com/mypdf.php
firefox http://www.example.com/mypdf.php
iexplore http://www.example.com/mypdf.php
Alternatively, if you're indeed running PHP as CLI-only, see #sectus' answer.