JavaScript-making PHP preview editor with Codemirror

Source: Internet
Author: User
Tags php editor

Target: I want to make a PHP editor with preview (and can easily insert a page).

Action:

  1. Search (Google or Baidu) did not find any ready-made answers.
  2. Codemirror found in the search, I think it should be OK.
  3. Then download and unzip Codemirror (5.2version) to D-disk, D:\codemirror-5.2.
  4. In D:\codemirror-5.2\demo, there are many demos, of which preview.html is more appropriate.
  5. Open preview.html with chrome, test JavaScript and HTML, all OK.
  6. I would like this effect (preview.html), but to PHP version, so I copy preview.html, and named Phppreview.html, put in D:\codemirror-5.2\demo.
  7. In notepad++ open phppreview.html, follow the steps below to modify it.
  8. Line 3, changed title to codemirror:php Preview.
  9. After line, add a new line:.
  10. Line PNs and 42,change "HTML5 preview" to "PHP Preview".
  11. Line A, change mode from "Text/xml" to "application/x-httpd-php".
  12. no other changes, open phppreview.html in Chrome, test PHP code, code output and code highlighting are not working!

Questions: I want to insert a PHP editor with a preview function (implemented with CODEMIRROR) in a page, how to make? What is wrong with the above steps? or what steps need to be added?

Thank you very much!

Note: The issue has been submitted in StackOverflow but has not received a reply for two weeks. Hope in Segmentfault can get enthusiastic expert guidance!

HTML editor with preview:

PHP editor with preview:

You might want http://3v4l.org. /

As far as I do, Codemirror is just an editor, except editor, you say the function must have a suitable sandbox environment to execute PHP code, the editor must be unable to execute the PHP code
such as https:// Github.com/fieryprophet/php-sandbox seems to be able to use the

You can take a look at this demo and hope it works for you:
Http://www.365mini.com/diy.php?f=jquery-on-de Mo

PHP is a service-side language that cannot be previewed by clients alone. You can make a button and then Ajax to the server to run, of course, to set security issues.

  • & #xe63a;
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.