<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=PHP%3A_Memanggil_python</id>
	<title>PHP: Memanggil python - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=PHP%3A_Memanggil_python"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=PHP:_Memanggil_python&amp;action=history"/>
	<updated>2026-04-20T04:34:48Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=PHP:_Memanggil_python&amp;diff=44335&amp;oldid=prev</id>
		<title>Onnowpurbo: New page: Sumber: http://stackoverflow.com/questions/166944/calling-python-in-php  ==Contoh 1==  You can run a python script via php, and outputs on browser.  Basically you have to call the python s...</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=PHP:_Memanggil_python&amp;diff=44335&amp;oldid=prev"/>
		<updated>2015-08-27T22:58:25Z</updated>

		<summary type="html">&lt;p&gt;New page: Sumber: http://stackoverflow.com/questions/166944/calling-python-in-php  ==Contoh 1==  You can run a python script via php, and outputs on browser.  Basically you have to call the python s...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sumber: http://stackoverflow.com/questions/166944/calling-python-in-php&lt;br /&gt;
&lt;br /&gt;
==Contoh 1==&lt;br /&gt;
&lt;br /&gt;
You can run a python script via php, and outputs on browser.&lt;br /&gt;
&lt;br /&gt;
Basically you have to call the python script this way:&lt;br /&gt;
&lt;br /&gt;
 $command = &amp;quot;python /path/to/python_script.py 2&amp;gt;&amp;amp;1&amp;quot;;&lt;br /&gt;
 $pid = popen( $command,&amp;quot;r&amp;quot;);&lt;br /&gt;
 while( !feof( $pid ) )&lt;br /&gt;
 {&lt;br /&gt;
  echo fread($pid, 256);&lt;br /&gt;
  flush();&lt;br /&gt;
  ob_flush();&lt;br /&gt;
  usleep(100000);&lt;br /&gt;
 }&lt;br /&gt;
 pclose($pid);&lt;br /&gt;
&lt;br /&gt;
Note: if you run any time.sleep() in you python code, it will not outputs the results on browser.&lt;br /&gt;
&lt;br /&gt;
For full codes working, visit How to execute python script from php and show output on browser&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Contoh 2==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The backquote operator will also allow you to run python scripts using similar syntax to above&lt;br /&gt;
&lt;br /&gt;
In a python file called python.py:&lt;br /&gt;
&lt;br /&gt;
 hello = &amp;quot;hello&amp;quot;&lt;br /&gt;
 world = &amp;quot;world&amp;quot;&lt;br /&gt;
 print hello + &amp;quot; &amp;quot; + world&lt;br /&gt;
&lt;br /&gt;
In a php file called python.php:&lt;br /&gt;
&lt;br /&gt;
 $python = `python python.py`;&lt;br /&gt;
 echo $python;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Referensi==&lt;br /&gt;
&lt;br /&gt;
* http://stackoverflow.com/questions/166944/calling-python-in-php&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>