Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <?php
  2. /**
  3. * Format Class
  4. */
  5. class Format{
  6. public function formatDate($date){
  7. return date('F j, Y, g:i a', strtotime($date));
  8. }
  9.  
  10. public function textShorten($text, $limit = 400){
  11. $text = $text. " ";
  12. $text = substr($text, 0, $limit);
  13. $text = substr($text, 0, strrpos($text, ' '));
  14. $text = $text.".....";
  15. return $text;
  16. }
  17.  
  18. public function validation($data){
  19. $data = trim($data);
  20. $data = stripcslashes($data);
  21. $data = htmlspecialchars($data);
  22. return $data;
  23. }
  24.  
  25. public function title(){
  26. $path = $_SERVER['SCRIPT_FILENAME']; //Çalışmakta olan PHP dosyasının tam yol tanımlamasını verir (C:/wamp/www/deneme/index.php gibi).
  27. $title = basename($path, '.php'); //Meselen: Yukaridaki urlden yalniz index kelimesini donderir
  28. //$title = str_replace('_', ' ', $title);
  29. if ($title == 'index') {
  30. $title = 'home';
  31. }elseif ($title == 'contact') {
  32. $title = 'contact';
  33. }
  34. return $title = ucfirst($title); //ucfirst komutu bir kelimenin ilk harfini büyük harfe dönüştürmeye yarar.
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement