Indian Posted June 7, 2009 Report Share Posted June 7, 2009 <?php class smth { function smth() { $var = 'text'; } function other() { echo $var; } } $smth = new smth; echo $var; ?> Kāpēc 'text' netiek izvadīts, un kādi var būt risinājumi? paldies. Quote Link to comment Share on other sites More sharing options...
bubu Posted June 7, 2009 Report Share Posted June 7, 2009 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(); ?> Quote Link to comment Share on other sites More sharing options...
Indian Posted June 11, 2009 Author Report Share Posted June 11, 2009 (edited) 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 June 11, 2009 by Indian Quote Link to comment Share on other sites More sharing options...
bubu Posted June 11, 2009 Report Share Posted June 11, 2009 Kāpēc lai tas izvadītos? Quote Link to comment Share on other sites More sharing options...
Indian Posted June 11, 2009 Author Report Share Posted June 11, 2009 kurā vietā $seven tiek kaut kas piešķirts? nu it kā : $seven = $this->three; ?? es domāju Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted June 11, 2009 Report Share Posted June 11, 2009 mainīgo redzamības scope Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.