Вопрос от новичка по пользовательской функции php
Только начал осваивать PHP и столкнулся с такой проблемой Есть кусок кода, который хочу обернуть в функцию
if($matches_url[0][0] == "pirs"){
$color = "red";
$name = "svadba";
$create_label = "https://api.trello.com/1/cards/" . $idcard . "/labels" . $key_token . "&color=" . $color . "&name=" . $name;
$headers = stream_context_create(array(
'http' => array(
'method' => 'POST',
),
));
echo file_get_contents($create_label, false, $headers);
}
Оборочиваю это всё в функцию
function post_label($url_path){
if($matches_url[0][0] == $url_path){
$color = "red";
$name = "svadba";
$create_label = "https://api.trello.com/1/cards/" . $idcard . "/labels" . $key_token . "&color=" . $color . "&name=" . $name;
$headers = stream_context_create(array(
'http' => array(
'method' => 'POST',
),
));
echo file_get_contents($create_label, false, $headers);
}
}
вызываю функцию
post_label("pirs");
И не работает ))) А без функции работает Спасибо! )