Phprad Global functions October 26, 2018, 01:55:04 AM Phprad Global functionsPlease Note: This Constant can be accessed in any Page or PHP Class.USER_IDReturn Active User ID if logged inUSER_NAMEReturn Active User Name if logged inUSER_PHOTOReturn Active User photo if logged inUSER_EMAILReturn Active User Email if logged inUSER_ROLEReturn Active User Role if logged inSITE_NAMEReturn Application|Site NameSITE_ADDRReturn site AddressExample http://localhost/sitename/SITE_LOGOReturn site logo image srcExample http://localhost/sitename/assets/images/logo.pngSITE_FAVICONReturn site favion image srcExample http://localhost/sitename/assets/images/favicon.pngHelper FunctionPlease these functions are to be used at the server sideget_active_user($field=null)Get Logged In User Details From The SessionGet particular field value of the active user otherwise return array of active user fieldsReturn Value Type: array | stringecho get_active_user('user_city');user_login_status()Check if there is active User Logged InReturn Value Type: booleanauthenticate_user()Authenticate And Check User Page Access EligibilityReturn Value Type: Redirect to Login Page Or Displays Error Message When user access control authorization Failsis_mobile()Check if current browser platform is a mobile browser Can Be Used to Switch Layouts and Views on A Mobile PlatformReturn Value Type: booleanprint_link($path=null)Echo Absolute Url Address of a pathExample : <a href="<?php print_link('users/add'); ?>">Add Users</a>set_url($path=null)Return Absolute Url Address of a pathset_img_src($imgsrc,$width=null,$height=null)Convinient Function To Resize Image Via Url of the Image Src if the src is from the same origin then image can be resizeExample : <img src="<?php echo set_img_src('uploads/images/89njdh4533.jpg',50,50); ?>" />;datetime_now()will return current DateTime in Mysql Default Date Time Format (Y-m-d H:i:s)Example : 2017-02-13 03:15:00time_now()will return current Time in Mysql Default Date Time Format (H:i:s)Example : 03:15:00date_now()will return current Date in Mysql Default Date Time Format (Y-m-d)Example: 2017-02-13relative_time($date=null)Parse Date Or Timestamp Object into Relative TimeExample : 2 days ago 2 days from nowhuman_date($date=null)Parse Date Or Timestamp Object into Human Readable DateExample : 26th of March 2016human_datetime($date=null)Parse Date Or Timestamp Object into Human Readable DateExample : 26th of March 2016 02:30 pmrandom_chars($limit=12,$context='...')Generate a Random String and characters From Set Of supplied data contextExample : f#8Gt4!a@hdtrandom_str($limit=12,$context='...')Generate a Random String From Set Of supplied data contextExample : Ga89KJ67adf4random_num($limit=6,$context='1234567890')Generate a Random Number From Set Of Supplied NumbersExample : 681423random_color($alpha=1)Generate a Random color StringExample : rgba(230,12,9,0.5)set_flash_msg($msg,$type="success",$dismissable=true,$showduration=5000)Set Msg that Will be Display to User in a Session. Can Be Displayed on Any View.show_flash_msg()Display The Message Set In MsgFlash Session On Any Page. Will Clear The Message Afterwardsredirect_to_page($path=null)Convinient Function To Redirect to Another PageExample : redirect_to_page("users/view/".USER_ID); Should not be use in view pages. Only in Controller pageredirect_to_action($action_name=null)Convinient Function To Redirect to Page ActionExample redirect_to_action('add'); Should not be use in view pages. Only in Controller pageredirect($url)Convenient Function To Redirect to External URLShould not be used in view pages. Only in Controller pageapproximate($val, $decimal_points=2)Approximate to nearest decimal pointsExample 3784.7466477 » 3784.75to_currency($val, $lang = 'en-US')Format string to country currencyExample 5000 » $5,000to_number($val, $lang = 'en-US')return a numerical representation of the string grouped in different unitsExample 247704360 » 247,704,360str_truncate($string, $length=50, $ellipse= '...')Trucate stringExample This is PhpRad Classic » This is PhpRad...number_to_words($val,$lang="en")Convert numerical value to word representationExample 247704360 » two hundred forty-seven million seven hundred four thousand three hundred sixtyset_cookie($name,$value,$days=30)Set a browser cookieget_cookie($name)Return a cookie valueclear_cookie($name)Delete a cookiehttp_post($name)Convenient function to retrieve content of from external Url Using CURL POST Requesthttp_get($name,$params=array())Convenient function to retrieve content of from external Url Using CURL GET RequestA Quote Selected Last Edit: October 27, 2018, 07:57:34 PM by Emman