How to change directory? in PHP -


when worked wamp, had no problems, because have of files in same directory, using hosts server, have change path file working with, py files work. hello.php in /public_html/wp-content/plugins , py, php working with, in /public_html/cgi-bin. hello.php code:

<?php # -*- coding: utf-8 -*- /* plugin name: hello */                     header('content-type: text/html; charset=cp1252'); add_shortcode( 'hello', 'execute_python_with_argv' );    function execute_python_with_argv(){             ob_start(); $description = array (      0 => array("pipe", "r"),  // stdin 1 => array("pipe", "w"),  // stdout ); $application_system = "python "; $application_path .= plugin_dir_path( __file__ ); $application_name .= "hello.py";                 $separator = " "; $application = $application_system.$application_path.$application_name.$separator; $pipes = array(); $proc = proc_open ( $application , $description , $pipes ); if (is_resource ( $proc )) { echo stream_get_contents ($pipes [1] ); //reading stdout buffer } echo "soup"; $output = ob_get_clean(); return $output; } 

i have tried changing $application_path .= plugin_dir_path( __file__ ); $application_path = $_server['document_root']; $application_path .= "/public_html/cgi-bin/hello.py"; didn't anything. appreciated, reading.

use chdir , getcwd functions.

getcwd — gets current working directory

chdir — change directory

changes php's current directory directory.

<?php  // current directory echo getcwd() . "\n";  chdir('cvs');  // current directory echo getcwd() . "\n";  ?> 

the above example output similar to:

/home/didou /home/didou/cvs 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -