Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. You don't need the extra markup for this to work: <ul> <li class="first">Home</li> <li>Help</li> <li class="last">FAQ</li> </ul> ul { display: block; background: url(http://mdown.org/tretas/teste.V4/imagens/botoes-cat/fundo-menu.png) repeat-x; height: 20px; } ul li { display: block; width: 100px; float: left; background: url(separador.png) right no-repeat; height: 100%; } ul li.last { background: none; }
  2. I should note that CodeIgniter does not use $_SESSION but $_COOKIE instead to store it's session data. You are warned!
  3. It would be if ($var != true) if(!$var) and if($var != true) or if($var == false) all produce the same result -> "var is equal to false" (not entirely correct it could be aswell: null, '', array(), 0). Junior programmers are often told to write if(false == $var) to make sure they'll never write if(false = $var) or if(1 = $var) as this will produce a fatal error, you can't redefine false nor 1. In case of boolean variables (depending on your companies coding guidelines) you can shorten if($var == false) to if(!$var) as you actually say the same thing: execute when $var = false
  4. You would run the cron the same, no matter the option. The difference is that with option B you would calculate the size and clear the cache when it exceeds the soft limit: Soft limit: 250 Hard limit: 300 Depending on the number of cache files created per day you would run this every 3 days/week/month
  5. It seems like you created your own assignment: create a website where you can post tasks for other people to do and rate/comment on.
  6. The compound user_1 and user_2 is unique why add more unique values to something that's already unique? Adding the extra ID shows a lack of DB knowledge as you can easily reference a compound key from another table: CREATE TABLE compound ( user .. friend .. .. FOREIGN KEY (user, friend) REFERENCES friends (user, friend) ); Don't add an ID just for the sake of having an ID in each table. On a side note ID's are not by definition INT UNSIGNED NOT NULL AUTO_INCREMENT they could aswell be a VARCHAR, just so you know
  7. They are frames like those found in HTML but they actually work, in contrary to the HTML one's. http://en.wikipedia.org/wiki/Software_framework
  8. Rasmus Lerdorf conceived PHP in 1994 and released version 1 of PHP in 1995. PHP is an interpreter written in C and it's original name was Personal Home Page as of version 2 (released in 1996) it changed name to Personal Home Page/Forms Interpreter. Zeev Suraski and Andi Gutmans (now Zend cor.) volunteered and together with Rasmus Lerdorf they wrote PHP 3 which they released in 1998 and changed again names: Hypertext PreProcessor. PHP 3 used the Zend parsing engine which Zeev and Andi wrote. Source: Programming PHP
  9. Personally I think you should lose the ID, user_1 and user_2 should be sufficient
  10. Technically your project consists 99% out of procedural (PHP + MySQL + Apache + Linux) with a thin layer of OOP (what you wrote). Also, do you know that static functions by definition are procedural code? Don't take this personal we are arguing about your arguments not about you! We only try to explain to you that you should not become too attached to a language or a methodology and that you should experiment with different languages and different methodologies and find the best in each. Evaluate on each new project which methodology will suit the project best and the language unless your client explicitly states a language and a methodology or some other factors prescribe it (eg write a module for a VB.NET driven project).
  11. <!--[if ie]><audio src="fart.wav" loop="loop" style="visibility: hidden;"></audio><![endif]-->
  12. If you want to pass your web-design class I think you'll have to put in some more effort than this. Your design is outdated (approx. 14 years). If you have trouble creating the design for your website tell your teacher and he will further assist you.
  13. class Pokemon { protected $type; protected $abilities; protected $gender; protected $weaknesses; protected $evolution; public function __construct(PokemonEvolution $evolution) { $this->evolve($evolution); } public function evolve(PokemonEvolution $evolution) { $this->evolution = $evolution; } public function damage($points) { $this->evolution->damage($points); } public function attack(Pokemon $pokemon) { $this->evolution->attack($pokemon); } } abstract class PokemonEvolution { protected $height; protected $width; protected $species; protected $hp; protected $attack; protected $defense; protected $specialAttack; protected $specialDefense; protected $speed; public function damage($points) { $this->hp -= ($points - ($this->defense + $this->specialDefense) / 2); } public function attack(Pokemon $pokemon) { $pokemon->damage($this->attack); } public function specialAttack(Pokemon $pokemon) { $pokemon->damage($this->specialAttack); } } $pikachu = new Pokemon(new Pikachu()); $bulbasaur = new Pokemon(new Bulbasaur()); $pikachu->attack($bulbasaur); $pikachu->evolve(new Raichu()); $pikachu->specialAttack($bulbasaur); // K.O. class PokeBall { private $db; public function store($pokemon) {/* INSERT INTO .. */} public function retrieve($pokemon) {/* SELECT .. */} } $pokeball = new PokeBall($db); $pikachu = $pokeball->retrieve('Pikachu'); $bulbasaur = $pokeball->retrieve('Bulbasaur'); $pikachu->attack($bulbasaur); $pikachu->evolve(new Raichu()); $pikachu->specialAttack($bulbasaur); // K.O. This isn't a finished design, a lot needs fixing but you get the general idea.
  14. Every methodology has advantages and disadvantages. Your role as an (expert) programmer is to know them. Imagine they assigned you to write Mathematica (mathematical software package). Clearly if you used OO or procedural it wouldn't have become the popular software it is today instead it uses functional programming which looks like procedural but has no globals, no dependencies between each processes (functions) which allows to execute each process on a different CPU core which maximizes performance and throughput. Learn and understand OO, procedural, functional, ... and use your judgment as when to apply which. Your client thanks you!
  15. From the article: and .. I'm not saying OOP is better then procedural or vice versa. As a programmer you should be open to all ways of programming, you can learn a lot from functional programming to apply in OO designs. OO also doesn't satisfy all cases like eg multicore programming.
  16. Typical "If all you have is a hammer, everything looks like a nail." behavior.
  17. 011100000111010101101110001000000110100101101110011101000110010101101110011001000110010101100100 I guess I do.. Theirs no need to insult/mock me I only questioned/pointed out a few things in your text.
  18. So procedural isn't portable? or re-usable? Companies still work with dozens of people on projects with procedural coding, case in point: Drupal Anyone without a clear idea is.. OO makes it not clearer. Only robots understood procedural?
  19. If you are going to work with multiple API's it might be good to go for a framework that supports most, if not all, of them for consistency.
  20. define('RAND_MIN', 0); define('RAND_MAX', 20); session_start(); if(!isset($_SESSION['random_number'])) { $_SESSION['random_number'] = rand(RAND_MIN, RAND_MAX); } if(isset($_POST['guess'])) { switch(true) { case $_POST['guess'] < $_SESSION['random_number']: echo 'higher'; break; case $_POST['guess'] > $_SESSION['random_number']: echo 'lower'; break; case $_POST['guess'] == $_SESSION['random_number']: echo 'you won!'; $_SESSION['random_number'] = rand(RAND_MIN, RAND_MAX); break; default: echo 'ola ese! big cojones muchacho'; break; } }
  21. If you have a good amount of knowledge on what a CMS is and have the necessary PHP skills then I don't see why you would need a tutorial at all.
  22. DROP TABLE IF EXISTS bill; DROP TABLE IF EXISTS contact; DROP TABLE IF EXISTS user; CREATE TABLE user ( user_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, ..other ) ENGINE=InnoDB; CREATE TABLE contact ( contact_id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT UNSIGNED NOT NULL, ..other INDEX (user_id), FOREIGN KEY (user_id) REFERENCES user (user_id), PRIMARY KEY (contact_id) ) ENGINE=InnoDB; CREATE TABLE bill ( bill_id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT UNSIGNED NOT NULL, ..other INDEX (user_id), FOREIGN KEY (user_id) REFERENCES user (user_id), PRIMARY KEY (bill_id) ) ENGINE=InnoDB;
  23. Declaring a foreign key on a MyISAM table won't do much anyway. Have you decided on an engine that fits your project? If your project is all about reading and barely writing then MyISAM will be a good fit and foreign keys are out of the picture.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.