SHARE
TWEET

Untitled

a guest Jul 17th, 2017 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $mystring = system('python myscript.py myargs', $retval);
  2.    
  3. <?php
  4.  
  5. function PY()
  6. {
  7.  $p=func_get_args();
  8.  $code=array_pop($p);
  9.  if (count($p) % 2==1) return false;
  10.  $precode='';
  11.  for ($i=0;$i<count($p);$i+=2) $precode.=$p[$i]." = json.loads('".json_encode($p[$i+1])."')n";
  12.  $pyt=tempnam('/tmp','pyt');
  13.  file_put_contents($pyt,"import jsonn".$precode.$code);
  14.  system("python {$pyt}");
  15.  unlink($pyt);
  16. }
  17.  
  18. //begin
  19. echo "This is PHP coden";
  20. $r=array('hovinko','ruka',6);
  21. $s=6;
  22.  
  23. PY('r',$r,'s',$s,<<<ENDPYTHON
  24. print('This is python 3.4 code. Looks like included in PHP :)');
  25. s=s+42
  26. print(r,' : ',s)
  27. ENDPYTHON
  28. );
  29. echo "This is PHP code againn";
  30. ?>
  31.    
  32. $pyscript = 'G:wampwwwlltest.py';
  33. $python = 'C:\Python27\python.exe';
  34.  
  35. $cmd='$pyscript $python';
  36.  
  37. exec("$cmd", $output);
  38.    
  39. $i = `path/python.py`;
  40. echo $i;
  41.    
  42. $i = `path/python.py`;
  43. echo $i;
  44.    
  45. $i = `path/python.py`;
  46. echo $i;
  47.    
  48. hello = "hello"
  49. world = "world"
  50. print hello + " " + world
RAW Paste Data
Top