850 posts
  • Has been part of the Envato Community for over 1 year
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
uziiuzair says

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

2580 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 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.

850 posts
  • Has been part of the Envato Community for over 1 year
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 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?

1483 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+3 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.

850 posts
  • Has been part of the Envato Community for over 1 year
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 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.

850 posts
  • Has been part of the Envato Community for over 1 year
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 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 ?

1483 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+3 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.

850 posts
  • Has been part of the Envato Community for over 1 year
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
uziiuzair says

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

279 posts
  • Has sold $100+ on Envato Market
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.

850 posts
  • Has been part of the Envato Community for over 1 year
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 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