Jump to content
php.lv forumi

php klases


ric_ric

Recommended Posts

Varbūt par agru ar klasēm :)

 

Derētu palasīt par formām un If konstrukciju.

 

http://www.w3schools.com/php/php_post.asp

 

http://w3schools.com/PHP/php_if_else.asp

 

if ($selected_radio == 'gailis') {
$lietotajs = new gailis();
echo "Gailim ir " .$lietotajs->kaajas ." kaajas<br>";
}


if ($selected_radio == 'suns') {
$lietotajs = new suns();
echo "Gailim ir " .$lietotajs->kaajas ." kaajas<br>";
}

 

Sapratu. Vakar nebija domājamais.

Ar šādu metodi jāraksta daudz if, ja man būs daudz klases, bet vai ir kāds veids

 

kā to visu padarīt īsāku, teiksim

$lietotajs = new gailis();
echo "Gailim ir " .$lietotajs->kaajas ." kaajas<br>";

 

 

lai tur kur šobrīd ir new gailis()

varētu ielikt klašu variabli, kas attiecīgi mainītos pēc post vērtības.

Cerams manu murgojumu saprati, paldies. :)

Edited by ric_ric
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...
×
×
  • Create New...