我正在尋找一種方法將我的PHP代碼結合到我的Python文件中。也許很奇怪,但對我來說這將是非常有用的。我只是想在Python的PHP代碼的這一部分,因爲我不知道該如何重寫它在Python :(如何在Python中結合使用php和python代碼
function counter_winkelkar()
{
global $order;
global $refname;
if(isset($_POST['clearknop']))
{
$_SESSION['count']= '0';
unset($_SESSION['array_products']);
unset($_SESSION['array_counting_products']);
}
if (isset($_POST['refname']))
{
$_SESSION['count']= $_SESSION['count'] + $order;
print("$_SESSION[count]");
}
}
function products_winkelkar()
{
global $order;
global $db;
global $refname;
if (!isset($_SESSION['array_products']))
{
$_SESSION['array_products'] = Array();
$_SESSION['array_counting_products'] = Array();
}
if ($order != 'number')
{
array_push($_SESSION['array_products'],$refname);
array_push($_SESSION['array_counting_products'],$order);
}
}
function winkelkar()
{
counter_winkelkar();
products_winkelkar();
}
winkelkar();
?>
您的PHP公司de引用了$ _POST和$ _SESSION,它表示它將在http服務器的上下文中運行。 Python如何適應這種設置? – 2013-04-29 20:54:03
他希望它改寫爲python – 2013-04-29 20:54:41