Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Code Completion for php SPL, DOM and PDO (PHP v5)Setup project with scripts located out of the web tree>
Last updated: Sat, 30 Dec 2023

HOWTO: Use a php script for my editing

I want to pass the text that is selected in my editor to a php script, make modifications to the text and then return it back to the editor. So far I know how to run a php script externally from the customizations setting but I don't know how to pass the text in the editor to that script.

Please follow the instructions below:
  • 1. Create a customization entry (a menu item)
  • 2. Set Execute With -> Shell
  • 3. Command line should be
    @PHP@ -q "full_path_to_my_script\myscript.php"
  • 4. Other settings:
    • -check "Show this command in File Bar popup
    • -check "Work with editor"
    • -check "Take input from..."
    • -check "Selected text"
    • -check "Return results to the editor"
    The other settings can be left by default or you can set them according to your needs.
  • 5. your script should read input stream for processing and echo results back, for example:
    <?php
    $f = fopen("php://stdin", "r");
    $s = fread($f, 100000); // should be big enough
    fclose($f);
    echo "\"" . $s . "\"";
    ?>

Please note, that input stream will be ended with "\n" (line feed), regardless whether you selected a single char or whole the line. Very useful scripts integrated this way can be found there.

Very useful scripts integrated this way can be found there:
some-useful-scripts-for-phped-t1989.html
script-to-automate-writing-of-set-get-functions-oop-phpdoc-t3192.html


<Code Completion for php SPL, DOM and PDO (PHP v5)Setup project with scripts located out of the web tree>
Last updated: Sat, 30 Dec 2023