Who could illustrate PHP?

Honestly, thank you both for your advices,I will do that, means, continue the learning level by level + finding this book

Hello all,
I really miss your advices.
Ok I’m learning now the book, and finished the php course on codecademy.
I want to show you what I did ( just to learn) and I enjoyed 2 things /
A : The fact that I did the small idea that I want to do
B : The fact that I touched how much your are nice people before being developers, so Thanks again for your advices.

<?php
require ('_showerrors.php');
class Names{
 private $a; 
 private $b;
 private $c;
 private $d;
 public function __construct($a,$b,$c,$d){
    $this->a = $a;
    $this->b = $b;
    $this->c = $c;
    $this->d = $d;
 }
 public function toArray(){
  $myArray = array($this->a, $this->b, $this->c, $this->d);
  shuffle ($myArray);
  return $myArray;
 }
}

$hello = new Names(" Apple "," Born "," Content "," Document ");
$values = $hello->toArray();
echo "A random result : <br>";
foreach($values as $val) {
  echo $val.', ';
}
?>

Hi

A little tip. PHP has a special function to do what this part of your code does:

foreach($values as $val) {
    echo $val.', ';
}

That function is implode:

echo implode(', ', $values);
1 Like

Great #megazoid, your advices are always welcome, thanks you !!
VoilĂ , I just read a new thing. By the way, a question :
Should we (the learners who seek to become developers) memorize all the functions in PHP, to be able to make for example an interactive website or application ? Or we could just memorize the most used functions, and search for others over the web when we need ?

LOL, AFAIK there will not be a quiz later. :wink:

Seriously though, I think it is a good idea to look around the documentation to get an overview of what is there.
That way when you need to do something you’ll have an idea of where to look.

In my experience, “knowing” the functions isn’t a matter of memorizing them, it’s more a matter of using them often enough that you eventually just know them.

1 Like

Just knowing what types of functions there are should be sufficient. If you know there is a function that might do what you want then you can always look it up.

1 Like

That’s absolutely true.

When writing some part of code you just should think “hmm… this operation looks very common, they probably already have a function/library for that”. For example, you want to reverse order of elements in your array. How do you think, how many other programmers might want to do that in their code too? A lot, probably. So you can simply google “php reverse array” and it’ll bring a link to array_reverse() function for you immediately. I think this is a good practice to google before writing code. It saves a lot of time often, especially when you’re beginner.

3 Likes

Hahah who knows, maybe I will be able to develop a quiz soon :wink:

I like your advice, thank you !

I like your advice too, thank you !

I like always the way you explain the things. When you say “for example”, the text after those 2 words, will often be very helpful, and this is the way actually that I’m using to learn more, and to practice. I thought before that it is not a good way to think, or maybe just a personal solution that I found, BUT you just confirm me that it is good to google it and find available solutions before reinventing the wheel. thank you !

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.