1121 posts
  • 2 Years of Membership
  • Affiliate Level 1
  • Author Level 2
  • Collector Level 3
+6 more
uziiuzair
says

Domain undefined? Why is that?
Does it not work like html or something? :/

2627 posts Put a Donk On It
  • Weekly Top Seller
  • Elite Author
  • Exclusive Author
  • Featured Author
+11 more
ThemeProvince
says

Domain undefined? Why is that?
Does it not work like html or something? :/

The parser will look for $code which currently (until you include the other file) doesn’t exist so it will throw an error.

1121 posts
  • 2 Years of Membership
  • Affiliate Level 1
  • Author Level 2
  • Collector Level 3
+6 more
uziiuzair
says

Okay so my next question,
What is the purpose of a class?
Why cant I just add functions and give out the same results?

1565 posts
  • Affiliate Level 1
  • Author Level 5
  • Collector Level 2
  • Featured Author
+2 more
OriginalEXE
says

You can achieve same result in a multitude of ways in every language.

The question you need to ask yourself is, which way is easiest for maintenance and possible future expanding.

Classes are a great way of structuring your data, but you will learn that with experience.

1121 posts
  • 2 Years of Membership
  • Affiliate Level 1
  • Author Level 2
  • Collector Level 3
+6 more
uziiuzair
says

You can achieve same result in a multitude of ways in every language.

The question you need to ask yourself is, which way is easiest for maintenance and possible future expanding.

Classes are a great way of structuring your data, but you will learn that with experience.

That makes sense, Maybe because I am learning at a very low level, I might not be able to see the use.

1121 posts
  • 2 Years of Membership
  • Affiliate Level 1
  • Author Level 2
  • Collector Level 3
+6 more
uziiuzair
says
I’ve been trying to understand what this code means.
How does the loop work basically?
 $food = array('pizza', 'salad', 'burger');
        $salad = array('lettuce' => 'with',
                   'tomato' => 'without',
                   'onions' => 'with');

      // Looping through an array using "for".
      // First, let's get the length of the array!
      $length = count($food);

      // Remember, arrays in PHP are zero-based:
      for ($i = 0; $i < $length; $i++) {
        echo $food[$i] . '<br />';
      }

      echo '<br /><br />I want my salad:<br />';

      // Loop through an associative array using "foreach":
      foreach ($salad as $ingredient=>$include) {
        echo $include . ' ' . $ingredient . '<br />';
      }

The foreach loop that is. I understand the first loop since that is easy but how does the second one work? what is $include ?

1565 posts
  • Affiliate Level 1
  • Author Level 5
  • Collector Level 2
  • Featured Author
+2 more
OriginalEXE
says

Second loop basically goes through your array and gives you access to every pair in your array.

You have this:
array(
'lettuce' => 'with',
'tomato' => 'without',
'onions'  => 'with'
);
foreach ( $salad as $ingredient => $include ) {}
basically means: go through each pair in my array, put left side (lettuce, tomato, onions) into variable $ingredient, and right side (with, without) into variable $include.

Code loops through each pair, and you can do with array values whatever you need.

1121 posts
  • 2 Years of Membership
  • Affiliate Level 1
  • Author Level 2
  • Collector Level 3
+6 more
uziiuzair
says

Oh thanks :) It had me stuck for quite sometime.

321 posts
  • 1 Year of Membership
  • Author Level 3
BizLogic
says

The best way to learn coding is to work on a ‘real’ project. I recommend finding an Open Source project on SourceForge or GitHub & just go for it. Change or add new functionality. Google or find a PHP forum when you have problems. This method works. Just like learning a real (spoken) language. The best way to learn is to simply do it.

1121 posts
  • 2 Years of Membership
  • Affiliate Level 1
  • Author Level 2
  • Collector Level 3
+6 more
uziiuzair
says

The best way to learn coding is to work on a ‘real’ project. I recommend finding an Open Source project on SourceForge or GitHub & just go for it. Change or add new functionality. Google or find a PHP forum when you have problems. This method works. Just like learning a real (spoken) language. The best way to learn is to simply do it.

Thanks for the advice :) Ive actually been doing that for over a month now, I started of with basic wordpress themes actually (bad idea) and I did some of it, but I would basically copy paste most of the code, which in turn, did not help me much. So thats why I decided to learn it this way. I would work on some project after Im done with this :) (95% of the course completed)

by
by
by
by
by
by