Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $mystring = system('python myscript.py myargs', $retval);
- <?php
- function PY()
- {
- $p=func_get_args();
- $code=array_pop($p);
- if (count($p) % 2==1) return false;
- $precode='';
- for ($i=0;$i<count($p);$i+=2) $precode.=$p[$i]." = json.loads('".json_encode($p[$i+1])."')n";
- $pyt=tempnam('/tmp','pyt');
- file_put_contents($pyt,"import jsonn".$precode.$code);
- system("python {$pyt}");
- unlink($pyt);
- }
- //begin
- echo "This is PHP coden";
- $r=array('hovinko','ruka',6);
- $s=6;
- PY('r',$r,'s',$s,<<<ENDPYTHON
- print('This is python 3.4 code. Looks like included in PHP :)');
- s=s+42
- print(r,' : ',s)
- ENDPYTHON
- );
- echo "This is PHP code againn";
- ?>
- $pyscript = 'G:wampwwwlltest.py';
- $python = 'C:\Python27\python.exe';
- $cmd='$pyscript $python';
- exec("$cmd", $output);
- $i = `path/python.py`;
- echo $i;
- $i = `path/python.py`;
- echo $i;
- $i = `path/python.py`;
- echo $i;
- hello = "hello"
- world = "world"
- print hello + " " + world
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement