Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I have used PHP for a few years now, and here are my suggestions:

array_push() can be used to add multiple values into an array at once, but in your case, your pushing only one value in at a time which means you can use:

$ar[] = $key . "=" . $value

This should also speed up your code a little( What's better to use in PHP $array[] = $value or array_push($array, $value)? What's better to use in PHP $array[] = $value or array_push($array, $value)?).

die() is normally used when there is an error. It spits out a message to the user. If you are using this code to just connect to a MySQL database then change die(implode("&", $ar)); to echo(implode("&", $ar));

But honestly, you should be able to take out the respond() function if you are only using it to send an array to flash.

 // Connection could not be established
 if(!$this->con)
 {
 $this->response = array(
 "status" => "no_connection",
 "message" => "Could not connect to MySQL, try again later."
 );
 echo(implode("&", $this->response));
 }

I have used PHP for a few years now, and here are my suggestions:

array_push() can be used to add multiple values into an array at once, but in your case, your pushing only one value in at a time which means you can use:

$ar[] = $key . "=" . $value

This should also speed up your code a little( What's better to use in PHP $array[] = $value or array_push($array, $value)?).

die() is normally used when there is an error. It spits out a message to the user. If you are using this code to just connect to a MySQL database then change die(implode("&", $ar)); to echo(implode("&", $ar));

But honestly, you should be able to take out the respond() function if you are only using it to send an array to flash.

 // Connection could not be established
 if(!$this->con)
 {
 $this->response = array(
 "status" => "no_connection",
 "message" => "Could not connect to MySQL, try again later."
 );
 echo(implode("&", $this->response));
 }

I have used PHP for a few years now, and here are my suggestions:

array_push() can be used to add multiple values into an array at once, but in your case, your pushing only one value in at a time which means you can use:

$ar[] = $key . "=" . $value

This should also speed up your code a little( What's better to use in PHP $array[] = $value or array_push($array, $value)?).

die() is normally used when there is an error. It spits out a message to the user. If you are using this code to just connect to a MySQL database then change die(implode("&", $ar)); to echo(implode("&", $ar));

But honestly, you should be able to take out the respond() function if you are only using it to send an array to flash.

 // Connection could not be established
 if(!$this->con)
 {
 $this->response = array(
 "status" => "no_connection",
 "message" => "Could not connect to MySQL, try again later."
 );
 echo(implode("&", $this->response));
 }
Source Link
Chillie
  • 289
  • 1
  • 4
  • 16

I have used PHP for a few years now, and here are my suggestions:

array_push() can be used to add multiple values into an array at once, but in your case, your pushing only one value in at a time which means you can use:

$ar[] = $key . "=" . $value

This should also speed up your code a little( What's better to use in PHP $array[] = $value or array_push($array, $value)?).

die() is normally used when there is an error. It spits out a message to the user. If you are using this code to just connect to a MySQL database then change die(implode("&", $ar)); to echo(implode("&", $ar));

But honestly, you should be able to take out the respond() function if you are only using it to send an array to flash.

 // Connection could not be established
 if(!$this->con)
 {
 $this->response = array(
 "status" => "no_connection",
 "message" => "Could not connect to MySQL, try again later."
 );
 echo(implode("&", $this->response));
 }
lang-php

AltStyle によって変換されたページ (->オリジナル) /