Jump to content
php.lv forumi

Klases


Indian

Recommended Posts

Tev jāmācās par $this mainīgo. Un kodu vajag identēt, citādi miskaste sanāk.

<?php
 class smth
 {
function smth()
{
  $this->var = 'text';
}

function other()
{
  echo $this->var;
}
 }

 $smth = new smth();
 $smth->other();
?>

Link to comment
Share on other sites

Ok paldies,

 

<?php

class One 
{

 var $three;

 function One() 
 {
	 $this->three =  $this->two();
 }

 function two() 
 {
	 return 'four';
 }

 function five() {
	 $seven = $this->three;
	 require('six.php');
 }

}

$one = new One();
$one->five();

?>

 

 

<?php
//INCLUDE SIX.PHP
echo $seven;
?>

 

Man būtu vēlviens jautājums, kāpēc $seven netiek izvadīts?


Edited by Indian
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...