-3

PHP: strpos($haystack, $needle);

and

Python: haystack.find(needle)

It seems like python uses the latter method more often, and PHP the former. But is there a name for these two ways of doing it? I'm looking for the name of the style of programming.

Is it correct to call the one procedural and the other object-oriented programming? Or is that simplifying matters?

bluppfisk
  • 2,538
  • 3
  • 27
  • 56

1 Answers1

1

the first is a global function that takes two operands of some type and operates on them. its common in the older-style procedural programming paradigm.

the seconds is a member-function of the String class (of which "haystack" is an instance of) which takes one operand. its part of the object-oriented programming paradigm.

FuzzyAmi
  • 7,543
  • 6
  • 45
  • 79