Coding discussion

Chat about anything and everything non-Etrian related!

Moderator: ItL Moderators

User avatar
Maxine MagicFox
ItL Webmaster
Posts: 13474
Joined: Wed Feb 27, 2008 12:20 pm
Location: Pennsylvania
Contact:

Re: Coding discussion

Postby Maxine MagicFox » Sun Apr 14, 2013 5:43 am

I want to learn it, ABSOLUTELY, but I spent a whole hour today trying to figure it out when it's for a few simple lines of code.

Well, I'll take the comparison chart and try again. :\

I had made a little progress but this chart does show me a cleaner way of doing it that I wasn't aware of. :\ Hrrrm...

I do have one question, though, and this probably seems very newbish. What is the actual explanation in simple terms for ->. I've heard "object->property" but I'm not sure I fully understand. :\ We were not introduced to it in our classes.

[] - [] - [] - []

User avatar
negzee
ItL's resident princess
Posts: 4049
Joined: Sun Aug 31, 2008 6:45 pm
Location: Minnesoouuda
Contact:

Re: Coding discussion

Postby negzee » Sun Apr 14, 2013 3:04 pm

"object->property" is the simplest description of the object operator in PHP.

You can sorta (sorta) think of it like the slashes in a URL, if that helps. Objects can have other objects as properties and you'll often see that operator chained like object->object->....

User avatar
Maxine MagicFox
ItL Webmaster
Posts: 13474
Joined: Wed Feb 27, 2008 12:20 pm
Location: Pennsylvania
Contact:

Re: Coding discussion

Postby Maxine MagicFox » Sun Apr 14, 2013 6:29 pm


[] - [] - [] - []

User avatar
Reynard-Miri
Manticor
Posts: 3190
Joined: Tue Jul 10, 2012 5:09 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Coding discussion

Postby Reynard-Miri » Sun Apr 14, 2013 8:06 pm


User avatar
Maxine MagicFox
ItL Webmaster
Posts: 13474
Joined: Wed Feb 27, 2008 12:20 pm
Location: Pennsylvania
Contact:

Re: Coding discussion

Postby Maxine MagicFox » Sun Apr 14, 2013 8:21 pm

Ironically, Rey... that actually helped. >_>; That triggered a memory of my teacher saying that in class. Got out my old notes and figured it out. Objects are basically a clump of functions and shit like that.

[] - [] - [] - []

User avatar
negzee
ItL's resident princess
Posts: 4049
Joined: Sun Aug 31, 2008 6:45 pm
Location: Minnesoouuda
Contact:

Re: Coding discussion

Postby negzee » Sun Apr 14, 2013 8:32 pm

The precise definition of an object (in an object-oriented programming, or OOP, context) varies between languages, but the general notion of an object in most languages that have some kind of OO aspect to them is that of a container that bundles some variables and the functions (referred to as methods in PHP when part of an object) that operate on them.

In your snippet, $date is an object that is an instance of the DateTime class. Classes are essentially blueprints for making usable objects with the properties and behaviours described by that class.

$date->format(...) in your snippet is a reference to the format() method defined in the DateTime class.

The official Java tutorials site has a fairly casual and approachable , which applies to PHP as well.

User avatar
Maxine MagicFox
ItL Webmaster
Posts: 13474
Joined: Wed Feb 27, 2008 12:20 pm
Location: Pennsylvania
Contact:

Re: Coding discussion

Postby Maxine MagicFox » Sun Apr 14, 2013 11:32 pm


[] - [] - [] - []

User avatar
negzee
ItL's resident princess
Posts: 4049
Joined: Sun Aug 31, 2008 6:45 pm
Location: Minnesoouuda
Contact:

Re: Coding discussion

Postby negzee » Sun Apr 14, 2013 11:46 pm



The problem you're having with the second connection isn't with classes, but functions.

User avatar
Maxine MagicFox
ItL Webmaster
Posts: 13474
Joined: Wed Feb 27, 2008 12:20 pm
Location: Pennsylvania
Contact:

Re: Coding discussion

Postby Maxine MagicFox » Mon Apr 15, 2013 12:08 am

O_O Aw! GLOBAL!

^_^ FIXED!


*mutters* <_<; That wasn't very fun... I was so sure there was something more complicated I was doing wrong.

Anywho, though, considering you didn't say anything :3 I'm assuming I'm using the -> stuff correctly and the class is set up correctly (now that $link is set to GLOBAL)?

(BTW, XD I liked the tutorial hint treatment.)

[] - [] - [] - []

User avatar
Maxine MagicFox
ItL Webmaster
Posts: 13474
Joined: Wed Feb 27, 2008 12:20 pm
Location: Pennsylvania
Contact:

Re: Coding discussion

Postby Maxine MagicFox » Mon Apr 15, 2013 12:49 am

^_^ Oh, by the way - in case I haven't said it recently, negzee. THANK YOU SO MUCH FOR THE HELP! I appreciate your teaching me like this. <_<; Sorry for being such a n00b sometimes. And everyone else, too!

[] - [] - [] - []

User avatar
noodles
ItL Moderator
Posts: 11871
Joined: Wed Aug 20, 2008 3:08 am
Location: Orange County, CA
Contact:

Re: Coding discussion

Postby noodles » Mon Apr 15, 2013 3:06 am

You're welcome.


User avatar
Maxine MagicFox
ItL Webmaster
Posts: 13474
Joined: Wed Feb 27, 2008 12:20 pm
Location: Pennsylvania
Contact:

Re: Coding discussion

Postby Maxine MagicFox » Sat Apr 27, 2013 1:24 pm


[] - [] - [] - []

User avatar
negzee
ItL's resident princess
Posts: 4049
Joined: Sun Aug 31, 2008 6:45 pm
Location: Minnesoouuda
Contact:

Re: Coding discussion

Postby negzee » Sat Apr 27, 2013 6:17 pm

There's no mysqli equivalent to mysql_result(). The way you're doing it is perfectly fine, although I wouldn't bother to name the value of count(*), and would simply fetch_array() instead of fetch_assoc().

As for mysqli_result::free() and mysqli::close(), you generally don't try to test if they worked.

User avatar
Maxine MagicFox
ItL Webmaster
Posts: 13474
Joined: Wed Feb 27, 2008 12:20 pm
Location: Pennsylvania
Contact:

Re: Coding discussion

Postby Maxine MagicFox » Tue Jun 11, 2013 9:49 pm


[] - [] - [] - []

User avatar
Kimiko
Manticor
Posts: 6044
Joined: Wed Jun 18, 2008 9:31 am
Location: Leiden, Netherlands, EU
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Coding discussion

Postby Kimiko » Wed Jun 12, 2013 11:59 am

Could it be that a different ISP has different versions of essential software installed?
Kimiko

Rewatching: Beast Player Erin



[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
68 posts

Return to “Discussion Section”

Who is online

Users browsing this forum: No registered users and 35 guests