Search the Community
Showing results for tags 'extends'.
-
I need to add more code to an existing function located inside the parent class. I'm using code like this but can't get it working : // Parent class Default_Fields { public function fields() { $this->_fields = array() // Default Code } } // Child class More_Fields extends Default_Fields { public function fields() { $this->_fields = array() // Modified Code } } $new = new More_Fields; $new->fields(); The modified code in the child class is an extended version of whats in the parent. There's no errors but the additional code is not printing.
-
This code works without problems: <?php namespace NamespaceA; class A extends \NamespaceB\B {} namespace NamespaceB; class B {} But why the following code cause Fatal error: Class 'NamespaceB\B' not found in ...file? <?php namespace NamespaceA; class A extends \NamespaceB\B {} namespace NamespaceB; class B extends \NamespaceC\C {} namespace NamespaceC; class C {} And this code also works without problems: <?php namespace NamespaceA; class A extends \NamespaceB\B {} namespace NamespaceC; class C {} namespace NamespaceB; class B extends \NamespaceC\C {} Without any namespace, also Fatal error: Class 'B' not found in ...file: <?php class A extends B {} class B extends C {} class C {} Works without problems: <?php class A extends B {} class B {} And yes everything is in the same PHP file....
-
Hello, it's my first time in this forum, I hope somebody could help me with my bug I have an extended class called 'Show' from 'Database' has a method called 'get_time'.. and it could be with arguments 'm' for minutes or 'h' for hours the class works as expected in any empty file.php but causes problem with the form here's the method class Show extends Database { //other methods above here public static function get_time ($arg=null) { $days = self::retreive_days(); // $days is supposed to retreive this string "dai-3:20 sun-1:30 tue-5:1 wed-1:3" $weekDays = array( 'dai', 'sat', 'sun', 'mon', 'tue', 'wed', 'thu', 'fri' ); foreach ($days as $key => $value) { $dayz[] = substr($days[$key], 0, 3); } $random_num = 0; foreach ($weekDays as $key => $value) { $myTime[$key] = null; foreach ($dayz as $key2 => $value) { if ($weekDays[$key] == $dayz[$key2]) { $myTime[$key] = substr( $days[$random_num], 4, strlen($days[$random_num]) ); $random_num++; } } } if ($arg=='m') { foreach ($myTime as $key => $value) { $seperator = strpos($myTime[$key], ':'); $results[] = substr($myTime[$key], $seperator+1, strlen($myTime[$key])); } return $results; } elseif ($arg=='h') { foreach ($myTime as $key => $value) { $seperator = strpos($myTime[$key], ':'); $results[] = substr($myTime[$key], 0, $seperator); } return $results; } else { return $myTime; } } } my problem is when I call the call it hides part of the form without even show me any php errors here's snapshot for the normal and after calling the calls.. notice the end of v-scroll