예제 #1
0
        /// <summary>
        /// Checks whether a dereferenced variable is numeric.
        /// </summary>
        /// <param name="variable">The variable.</param>
        /// <returns>Whether <paramref name="variable"/> is integer, double or numeric string.
        /// <seealso cref="PHP.Core.Convert.StringToNumber"/></returns>
        public static bool is_numeric(PhpValue variable)
        {
            switch (variable.TypeCode)
            {
            case PhpTypeCode.Int32:
            case PhpTypeCode.Long:
            case PhpTypeCode.Double:
                return(true);

            case PhpTypeCode.String:
            case PhpTypeCode.MutableString:
                PhpNumber tmp;
                return((variable.ToNumber(out tmp) & Core.Convert.NumberInfo.IsNumber) != 0);

            default:
                return(false);
            }
        }