Jump to content
Larry Ullman's Book Forums

alvarito

Members
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

1 Neutral

About alvarito

  • Rank
    Newbie
  1. Hello This is an application of page 302, my variant exercise Been trying for the last two days to get the arguments sent by an object which calls a method, to an array which is in that method, and said array only gets the first of the arguments, as if it were a single scalar variable and not an array. UPDATE Someone solved the issue for me. The problem was that I was not passing the array into the object. I have to create the array, put the elements in there and then This is the code that sends the arguments require_once 'vehicle.php'; require_once 'Motorbike.php'; $v1 = 200; // actually these are distances run at after 5, 10 and 15 seconds $v2 = 300; $v3 = 450; $suzuki = new Motorbike(); $speeds = $suzuki->speed($v1, $v2, $v3); echo "Speeds are: "; foreach($speeds as $speed) { echo $speed . "<br />"; } UPDATED $v = array(50, 20, 600); $suzuki = new Motorbike(); $speeds = $suzuki->speed($v); echo "Speeds are: "; foreach($speeds as $speed) { echo $speed . "<br />"; } <?php class Motorbike extends Vehicle { protected $bikes_speed = array(); protected $speeds = array (); public function speed($speeds){ foreach($speeds as $speed) { $this->bikes_speed[] = $speed/5; } return $this->bikes_speed; } } but this public function with argument $speeds, which is an array, is not getting the 3 values that I sent it from the code above, only the 200
  2. Hello, On page 301 where it declares the abstract class and on the next page where it extends it, it turns out that no attribute is declared in the parent but only in the child class, namely triangle class. Since the parent is called "shape", wouldnt one put the main attributes there such as "$side" so that other shapes like rectangle can also use that ?. What would we do then when we create another extension like "class rectangle extends shape" , we are going to need the $sides again. thank you A
  3. Yes, very insightful, I think it is true, because there was a resemblance between your modularized web and the concept of framework.(I know you know all this but this is more for some of the audience who may not yet be familiar with the MVC concept). With the frameworks it is 3 sections, one called MODEL where you put all the code to interact with the DB, then you have the VIEW, which is basically an HTML page and is what the user sees, and then you have the CONTROLLER, which actually monitors the traffic, and this CONTROLLER is acting as the index.php that you have. In this controller you will see a command like $this->load->view('name_of_your_html_page'); So, now I find myself in the situation of which way to take, the MVC or the modularized web you introduced. The thing is that the framework, as you indicated in your book, do have a lot of built in classes and it is pretty evolved in terms of security, configurations etc, for example, it has an automatated detection of whether you are local or live and accordingly changes the error reporting status. The configuration page config.php that the framework has is tremendously rich in all settings you can customize so it does a great job. Basically what I am doing is understanding all the concepts which I find in your books and then try to implement them in my settings. In the past I coded my web http://www.matchandtravel.net fully procedural, as it was my first web and did not know about modularization of a Site etc and ended up with pages with over 1500 lines of code where all is mixed. They do work but I have to roll the mouse wheel for a while before I get to the line I want to modify. best regards Alvaro ==================================================================================================================================================================
  4. Thank you, I will give it a try and I will post whatever I get or not get. UPDATE hmm, you mean giving the full path from the base_url like this ? <link href="http://localhost/mvc/index.php/welcome/index/includes/style.css" rel="stylesheet" type="text/css" /> if yes, so far that did not solve it, hmm, I am sure it shouldnt be impossible, yet ... regards Alvaro _______________________________________________________________________________________________________________________________
  5. Hello Larry thank you for the reply. The latest path I included at the very bottom is not what is on my script. It was just the pasted result from the Firebug console indicating that it did not show an error. The correct paths that I was using are already in the files. As per the framework, alright, if that is the reason, I will have to continue by keeping the css code hardcoded in the header file instead of calling it. Even though I did start to suspect what you have clarified now, that indeed the ./includes/style.css is has that path because that is actually the path from the Index.php to the css and not the path from the header even though that code is hardcoded in the header file. This makes me think that it should be possible to reproduce that from CodeIgniter. CodeIgniter is about the best most simple framework I have seen and worked with, so it would be cool to integrate your model in a framework as an example, maybe some day. I tried smarty and symfony and zend and gave up, but codeigniter is so simple that in one day one gets started. Thank you for your great and very accesible explanations in your books (of which I already have 3) best regards Alvaro ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
  6. Hello I m reproducing the website from Chapter 2 Developing web app PHP5 advanced. I am doing it though using a framework (CodeIgniter) and well it is just about linking the header.html with the css style file. For some weird reason, it does not import it, the command <link href="style.css" rel="stylesheet" type="text/css" /> does not work. In the book the header file is in the same folder as the style.css, both of them in the includes folder, yet it is written as <hlink href="./includes/style.css" rel="stylesheet" type="text/css" />, (I have tried many other paths, too, also exactly the one from the book) but it will not pick it up. Only if I actually copy and paste the full css in the body of the header file, does the css work. The way I have it is: The index.php is in the View and within the View there is a folder called Includes, within which I have the header, the footer and the style.css. So, Index, is logically not inside the folder Includes, but inside the Section View (from the MVC framework). Index fetches header, and footer and modules alright because the paths are fine. Of course, what I am doing with CodeIgniter is not different from the book. It is the index.php the one what assembles the header, the modules and the footer. The fact that I load the View from the Controller does not have to make any difference as long as I call the index, then this file should gather the rest of the files, just as in the book. It does gather the header and the footer and the modules alright, but completely unformatted because the ridiculous issue of the css is not joining the group, unless I paste the full css code hardcoded it in the body of the header file. Would the MVC framework have an effect on why the header.html does not pick the css? I realize it is a first grade question, but I am puzzled why this simplicity is giving me trouble. Firebug reports a 200 OK to the query for the CSS, so it does actually find it. In fact, I changed the path to check and when it was wrong, firebug did report error. So it does fetch it. http://localhost/mvc/index.php/welcome/index/includes/style.css thank you Alvaro
×
×
  • Create New...