php - Duplicate function -


first, did resarch that. couldn't find solution that. here want do. have multiple files same function name, during test didn't specify function , kept simple.

the mulitple files included, since function been declared, i'm getting fatal error cannot redeclare function ..., declared in ...

i know how avoid fatal error since include multiple files same function don't fix it.

my question, logical, or should rethink , someting diffrent.

my friend told me handled objects , on.

thanks suggestion.

are functions identical? in case, may able "hack" around problem wrapping function declarations function_exists() clause, see how avoid fatal error cannot redeclare function in php:

<?php if (!function_exists('utility')) {   function utility() {     // ...   } } ?> 

alternatively, might worth time read on namespaces:

in php world, namespaces designed solve 2 problems authors of libraries , applications encounter when creating re-usable code elements such classes or functions:

  1. name collisions between code create, , internal php classes/functions/constants or third-party classes/functions/constants.
  2. ability alias (or shorten) extra_long_names designed alleviate first problem, improving readability of source code. (source)

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -