Functions that are nicknames (aliases) should be used or not?

Asked

Viewed 251 times

2

I remember that a while ago, when I was starting programming with PHP, I saw in some tutorials a recommendation, warning that it was to avoid using some functions that are nicknamed for others.

I don’t know if I’m wrong, but in the PHP Handbook itself, when you entered the page of a function that was an alias (for example session_commit and sizeof), had a warning something like this:

The function y is a nickname for the function x, therefore its use should be avoided as it can be removed in future versions.

I may be mistaken, but I have the impression that there was a time when you commented that new versions of php would remove all alias functions, to make the thing more organized.

But what I have noticed is that even after PHP 7 is released, the alias functions are still there, and there is no recommendation when using it or not the same.

Examples:

I would like to know if there is any danger in using these synonymous functions/nicknames on account of having risk of being removed in the future.

Using function nicknames could also be bad from the point of view of some standard PHP encoding, such as PSR?

For example, would have some problem using sizeof instead of using count?

1 answer

2


The ideal is always to use the root 'language' or the function’s orginal name. The team that takes care of the development does almost everything to maintain the compatibility newer versions with the previous ones so something disorganized take to get yourself elminado. Remember that these aliases have been defined in some context.

Functions that are used would hardly have any alias removed as for example join()/implode() as this would cause a huge code incompatibility.

Now an example of several deleted aliases is in the Mysqli library, see mysqli_bind_param() / mysqli_stmt_bind_param()

  • Nice, man. I got an example in the depreciation manual for being synonymous. I hunted it everywhere and I didn’t find, kkkk +1

  • @Wallacemaxters lacked a nose for finding :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.