Help php
#1

I look at a site php, to tell me a bit about the "function" and the "return" so I created two page, test and b.php

in test.php
PHP код:
<?php
include("b.php");
  for (
$i=0;$i<$count;$i++) 
  {
    echo 
"player: ".$data[$i]['player'].", <strong>score</strong> ".$data[$i]['score']."<br>";
  }
  
$data GetPlayers("51.254.29.46""30465");
  
$count count($data);
  for (
$i=0;$i<$count;$i++) {
    echo 
"player: ".$data[$i]['player'].", <strong>score</strong> ".$data[$i]['score']."<br>";
  }
?>
and in b.php
PHP код:
<?php
function GetPlayers($server_ip$server_port) {
  
$fp fsockopen('udp://'.$server_ip$server_port$errno$errstr);
  
stream_set_timeout($fp5);
  if (!
$fp) return false;
  
  
$packet 'SAMP';
  
$packet .= chr(strtok($ip'.'));
  
$packet .= chr(strtok('.'));
  
$packet .= chr(strtok('.'));
  
$packet .= chr(strtok('.'));
  
$packet .= chr($port 0xFF);
  
$packet .= chr($port >> 0xFF);
  
  
fwrite($fp$packet.'c');
  
fread($fp11);
  
$players ord(fread($fp2));
  
  
$start 0;
  if (
$players 0)    {
      for (
$i=0;$i<$players;$i++)    {
          
$strlen ord(fread($fp1));
          
$player fread($fp$strlen);
          
$score ord(fread($fp4));
          
$data[$start]['player'] = $player;
          
$data[$start]['score'] = $score;
          
$start++;
      }
  }
  
fclose($fp);
  return 
1;
}  
?>
the problem is always the same, when I put return 1;
he shows me in the page


and when I put return $data;
he shows me in the page



I try to understand this https://sampforum.blast.hk/showthread.php?tid=407156
Reply


Messages In This Thread
Help php - by Saliim - 26.04.2016, 17:53
Re: Help php - by Saliim - 29.04.2016, 10:42
Re: Help php - by [LTU]mindux9[TCS] - 29.04.2016, 11:38
Re: Help php - by Saliim - 29.04.2016, 12:51
Re: Help php - by Ritzy2K - 29.04.2016, 12:53
Re: Help php - by Saliim - 29.04.2016, 13:06

Forum Jump:


Users browsing this thread: 1 Guest(s)