Convert to PHP
Hey all I currently have a script that converts some output to a html file. They now would like it as a php file is there any way to do this? I did a little searching and couldn't find anything helpful. Thanks for any help!!
July 10th, 2015 12:07pm

Hi,

What exactly are you looking for? I doubt there's any utility that will take a prewritten PowerShell script and spit out a working PHP script.

Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 12:09pm

As Mike stated, there is no PowerShell to PHP as of now.  However, there are many HTML to PHP converters online.  Do a web search for HTML to PHP converter and take a look.
July 10th, 2015 12:20pm

As Mike stated, there is no PowerShell to PHP as of now.  However, there are many HTML to PHP converters online.  Do a web search for HTML to PHP converter and take a look.
Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 12:23pm

What is the purpose of converting HTML output to PHP? HTML is static content, PHP is a programming language, which makes static content more dynamic.
July 10th, 2015 12:31pm

Okay thanks for all the replies and sorry for the confusion. At the moment I have a script that outputs some WOL info to a html file:

$body = ConvertTo-Html -head $head -body "$($body)<H1>$Name</H1><H2>Wake on lan Report as of $end </H2>$($html)"| Out-String 
    $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False)
    [System.IO.File]::WriteAllLines($webfile, $body, $Utf8NoBomEncoding)

So it outputs it as a html file. Truly all I want is for the file extension to be .php instead of .html. Is this possible? Thanks!

Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 1:48pm

I think this works:

Rename-Item -Path test.html -NewName test.php

I was just hoping there was a way to output it directly as a php file instead of html. Thanks.

July 10th, 2015 1:59pm

Where is the rest of your script? Where did you give $webfile a value?
Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 2:02pm

As Leif points out, that is only a subset of the script. Since you are doing

  [System.IO.File]::WriteAllLines($webfile, $body, $Utf8NoBomEncoding)

I will assume $webFile is something like

$webFile = "C:\myFiles\myfile.html"
Why not just change the extension to php? ConverTo-Html, just creates the HTML markup for you, you are the one that is creating the html extension for the file.
July 10th, 2015 2:07pm

You're right I'm sorry I though it was creating the .html file without me specifying. So all I needed to do is change:

$webfile = "$($rootDir)WakeOnLanReport$($Area).html"

to

$webfile = "$($rootDir)WakeOnLanReport$($Area).php"

Sorry guys I had a major brain fart. Thanks for the help though!!

Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 2:12pm

A PHP web server executes (delivers) HTML with no issues.  You only need a PHP extension when you want to embed server side code.  Same with ASP.

July 10th, 2015 2:13pm

Sorry guys I had a major brain fart. Thanks for the help though!!
No need to apologize, we've all done that before. Glad it worked out in the end.
Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 2:16pm

Sorry guys I had a major brain fart. Thanks for the help though!!

No need to apologize, we've all done that before. Glad it worked out in the
July 10th, 2015 2:19pm

As Mike stated, there is no PowerShell to PHP as of now.  However, there are many HTML to PHP converters online.  Do a web search for HTML to PHP converter and take a look.
  • Edited by bentek.nyc Friday, July 10, 2015 4:19 PM
Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 4:18pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics