804 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 1-2 years
  • Philippines
  • Referred between 1 and 9 users
  • Sold between 100 and 1 000 dollars
uziiuzair says

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

2566 posts Put a Donk On It
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Exclusive Author
  • Attended a Community Meetup
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Referred between 200 and 499 users
+5 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.

804 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 1-2 years
  • Philippines
  • Referred between 1 and 9 users
  • Sold between 100 and 1 000 dollars
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?

1466 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
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.

804 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 1-2 years
  • Philippines
  • Referred between 1 and 9 users
  • Sold between 100 and 1 000 dollars
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.

804 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 1-2 years
  • Philippines
  • Referred between 1 and 9 users
  • Sold between 100 and 1 000 dollars
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 ?

1466 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
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.

804 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 1-2 years
  • Philippines
  • Referred between 1 and 9 users
  • Sold between 100 and 1 000 dollars
uziiuzair says

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

238 posts
  • Exclusive Author
  • Has been a member for 0-1 years
  • Sold between 100 and 1 000 dollars
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.

804 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 1-2 years
  • Philippines
  • Referred between 1 and 9 users
  • Sold between 100 and 1 000 dollars
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