Jump to content
php.lv forumi

vai tukšums $_POST masīvā skaitās ka $_POST masīvs ir !e


L4URO
 Share

Recommended Posts

ja man ir 

if(Input::exists()){
  echo "yeaa"; 
}
public static function exists($type = 'post'){
		switch ($type) {
			case 'post': 
				return (!empty($_POST)) ? true : false;
			break;

			case 'get':
				return (!empty($_GET)) ? true : false;
			break;	
			
			default:
			  return false;
			break;
		}

	}

un tad man ir form ar vairakiem input fieldiem,ja pat es neko neaizpildu,bet uzspiezu submit pogu man uz ekrana izvada "yeaa"; ,bet kapec,ja es parbaudu vai $_POST vai $_GET masīvs (array) nav tukšs ,tad es atgriežu true un man darbojas viss iekšā if(Input::exists()){ } ????

 

tā tad sanāk,ka pēc submitošanas tukšums arī padara $_POST vai $_GET masīvus par netukšiem?

Link to comment
Share on other sites

var_dump($_POST);

 

un paskaties, kas skaitās empty()

 

tikai neieķeksēts checkbox un radio (un nepievienots file) netiek nopostots formā

jup,tukši arī ieiet POST arrayā,kad uzspiež submit

 

array (size=4) //man ir 4 input fieldi

'username' => string '' (length=0)

'password' => string '' (length=0)

'password_again' => string '' (length=0)

'name' => string '' (length=0)

Edited by L4URO
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...