PHP Variable return without call a 2nd time?

  curl, php

i have my curl code were i need to know the result of $value.
the code works but i don’t know the $value of the transactions.
When i try to return $value, i get the value but the call fires two times so it does two transactions.

How can i fix this?

<?php
  if (isset($_POST['submit'])) {
    someFunction();
  }
  function someFunction() {
    $value = rand(1,10)/100;
    $url = 'https://server.xxx.com/transaction/?username=xxx&password=xxx&recipient=' . $variable . '&amount=' . $value . '&memo=xxx';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds 

    $output = curl_exec($ch);
    curl_close($ch);
    
  }

?>

Source: Ask PHP

LEAVE A COMMENT