php function to remove trailing slashes from URL <?php private function _curSiteURL() { $pageURL = ‘http’; if ($_SERVER[“HTTPS”] == “on”) {$pageURL .= “s”;} $pageURL .= “://”; $pageURL .= $_SERVER[“SERVER_NAME”].dirname($_SERVER[‘SCRIPT_NAME’]).’/’; if (substr($pageURL, -1) == ‘/’ ): return substr($pageURL, 0, -1); else: return $pageURL; endif; } ?>
Tag: PHP
PHP foreach loop key value
PHP foreach loop key value foreach($data as $key => $value): echo $key; echo $value; endforeach; Example: <?php foreach($this->universities as $key => $value): if($key == $group->group_id): echo $value; endif; endforeach; ?>
php substr function
substr() is used to limit the post length. Syntax: substr($string,start position,end position) Example: <?php echo substr(“Hello smarttips”,0,4); ?> Output:Hello
jquery smooth scrolling of internal anchor links
jquery smooth scrolling of internal anchor links <script> jQuery(document).ready(function(){ jQuery(‘a[href^=”#”]’).on(‘click’,function (s) { s.preventDefault(); var smarttarget = this.hash, $smarttarget = jQuery(smarttarget); jQuery(‘html, body’).stop().animate({ ‘scrollTop’: $target.offset().top }, 900, ‘swing’, function () { window.location.hash = smarttarget; }); }); }); </script> <ul> <li><h1>Contents</h1></li> <li> 1. <a class=”msection” style=”color:#1155CC” href=”#section_1″>Tes1</a></li> <li> 2. <a class=”msection” style=”color:#1155CC” href=”#section_2″>Test 2</a></li> </ul> <a id=”section_1″…
TinyMCE editor with file Upload and ajaxfilemanager plugin
TinyMCE editor with file Upload and ajaxfilemanager plugin TinyMCE is a common editor used in php applications. It includes all common features of editors like fck editor,ck editor..etc. One thing is missing in TinyMCE is file uploading. This editor requires extra plugin for getting file upload feature. Steps for implementing TinyMce photo upload feature is…