Coder Social home page Coder Social logo

Execute .html as PHP about grunt-php HOT 4 CLOSED

sindresorhus avatar sindresorhus commented on July 19, 2024
Execute .html as PHP

from grunt-php.

Comments (4)

sindresorhus avatar sindresorhus commented on July 19, 2024

Don't know. This task uses the PHP built-in server. If that supports it, this task does too. Have you actually tried and it didn't work?

from grunt-php.

JohnCashmore avatar JohnCashmore commented on July 19, 2024

Hi,

I did try it and it didn't work, I mainly asked the question to see if you had explored the option, however i do know this isn't a problem everyone will have.

from grunt-php.

sindresorhus avatar sindresorhus commented on July 19, 2024

This might help (from the above link):

Example #5 Handling Unsupported File Types

If you need to serve a static resource whose MIME type is not handled by the CLI web server, use:

<?php
// router.php
$path = pathinfo($_SERVER["SCRIPT_FILENAME"]);
if ($path["extension"] == "ogg") {
    header("Content-Type: video/ogg");
    readfile($_SERVER["SCRIPT_FILENAME"]);
}
else {
    return FALSE;
}
?>

You can then set the mimetype of of html files to php.

from grunt-php.

yaworsw avatar yaworsw commented on July 19, 2024

(kind of late to the party but whatever)

Why not just use include?

<?php
// router.php

$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
$ext  = pathinfo($path, PATHINFO_EXTENSION);

if ($ext == "html") {
    include $path;
} else {
    return FALSE;
}

PHP's include (to my knowledge) does not care about the extension of the file you're including, it will just execute it as PHP.

from grunt-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.