课程: Level Up: PHP

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Create functions in a namespace

Create functions in a namespace - PHP教程

课程: Level Up: PHP

Create functions in a namespace

(chiptune music) (stars chiming) - [Instructor] Calculators are classic apps to learn how to write, but can be especially complicated depending on what you want to do. In the provided starter file, there are a set of functions to process two or three numbers. But what if you want to feed an array of numbers to the function and process them without renaming them? After all, what's a clearer name than add? That's where namespacing comes in. Namespacing allows you to keep function names while changing the scope of where their functions are referenced. And your challenge is to recreate all of the functions from the starter file in a separate namespace, called namespace.calculator.php. Here are the requirements. Create new functions that exactly match names of the functions in the starter file, in a new namespace. The namespace should be called calculator. These functions should process arrays, instead of a finite set…

内容