SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
CodeIgniter Helper Functions
Jamshid Hashimi
Trainer, Cresco Solution
http://www.jamshidhashimi.com
jamshid@netlinks.af
@jamshidhashimi
ajamshidhashimi
Afghanistan Workforce
Development Program
Agenda
• Array Helper
• Directory Helper
• Download Helper
• Email Helper
• File Helper
• Form Helper
• HTML Helper
• Text Helper
• URL Helper
Array Helper
• The Array Helper file contains functions that assist in
working with arrays.
• $this->load->helper('array');
– Loading helper
• element()
– Lets you fetch an item from an array.
• random_element()
– Takes an array as input and returns a random element
from it.
• elements()
– Lets you fetch a number of items from an array.
Directory Helper
• The Directory Helper file contains functions
that assist in working with directories.
• $this->load->helper('directory');
– Loading helper
• directory_map('source directory')
– This function reads the directory path specified in
the first parameter and builds an array
representation of it and all its contained files.
Download Helper
• The Download Helper lets you download data to
your desktop.
• $this->load->helper('download');
– Loading the helper
• force_download('filename', 'data')
– Generates server headers which force data to be
downloaded to your desktop. Useful with file
downloads. The first parameter is the name you want
the downloaded file to be named, the second
parameter is the file data.
Email Helper
• The Email Helper provides some assistive
functions for working with Email.
• $this->load->helper('email');
– Loading helper
• valid_email('email')
– Checks if an email is a correctly formatted email.
Note that is doesn't actually prove the email will
recieve mail, simply that it is a validly formed
address.
File Helper
• The File Helper file contains functions that assist in working
with files.
• $this->load->helper('file');
– Loading helper
• read_file('path')
– Returns the data contained in the file specified in the path.
• write_file('path', $data)
– Writes data to the file specified in the path. If the file does not
exist the function will create it.
• delete_files('path')
– Deletes ALL files contained in the supplied path.
– If the second parameter is set to true, any directories contained
within the supplied root path will be deleted as well.
File Helper
• get_filenames('path/to/directory/')
– Takes a server path as input and returns an array
containing the names of all files contained within it.
• get_dir_file_info('path/to/directory/', $top_level
_only = TRUE)
– Reads the specified directory and builds an array
containing the filenames, filesize, dates, and
permissions.
• get_file_info('path/to/file', $file_information)
– Given a file and path, returns the
name, path, size, date modified.
File Helper
• get_mime_by_extension('file')
– Translates a file extension into a mime type based on
config/mimes.php.
• symbolic_permissions($perms)
– Takes numeric permissions (such as is returned by
fileperms() and returns standard symbolic notation of
file permissions.
• octal_permissions($perms)
– Takes numeric permissions (such as is returned by
fileperms() and returns a three character octal
notation of file permissions.
Form Helper
• The Form Helper file contains functions that assist in
working with forms.
• $this->load->helper('form');
– Loading Helper
• form_open()
– Creates an opening form tag with a base URL built from your
config preferences.
– $attributes = array('class' => 'email', 'id' => 'myform');
– $hidden = array('username' => 'Joe', 'member_id' => '234');
• form_open_multipart()
– This function is absolutely identical to the form_open() tag
above except that it adds a multipart attribute, which is
necessary if you would like to use the form to upload files with.
Form Helper
• form_hidden()
– Lets you generate hidden input fields.
• form_input()
– Lets you generate a standard text input field.
• form_password()
• form_upload()
• form_textarea()
• form_dropdown()
– Lets you create a standard drop-down field.
• form_checkbox()
– Lets you generate a checkbox field.
• form_radio()
• form_submit()
• form_reset()
• form_button()
• form_close()
HTML Helper
• The HTML Helper file contains functions that assist in working with HTML.
• $this->load->helper('html');
– Loading helper
• br()
– Generates line break tags (<br />) based on the number you submit.
• heading()
– Lets you create HTML <h1> tags. The first parameter will contain the data, the
second the size of the heading.
• img()
– Lets you create HTML <img /> tags. The first parameter contains the image
source.
• nbs()
– Generates non-breaking spaces (&nbsp;) based on the number you submit.
Text Helper
• The Text Helper file contains functions that assist in working with
text.
• $this->load->helper('text');
– Loading helper
• word_limiter()
– Truncates a string to the number of words specified.
• character_limiter()
– Truncates a string to the number of characters specified.
• highlight_code()
– Colorizes a string of code (PHP, HTML, etc.).
• word_wrap()
– Wraps text at the specified character count while maintaining
complete words.
URL Helper
• The URL Helper file contains functions that assist in working with URLs.
• $this->load->helper('url');
– Loading helper
• site_url()
– Returns your site URL, as specified in your config file.
• base_url()
– Returns your site base URL, as specified in your config file.
• current_url()
– Returns the full URL (including segments) of the page being currently viewed.
• uri_string()
– Returns the URI segments of any page that contains this function.
• index_page()
– Returns your site "index" page, as specified in your config file.
URL Helper
• anchor()
– Creates a standard HTML anchor link based on your local site
URL
• anchor_popup()
– Nearly identical to the anchor() function except that it opens the
URL in a new window.
• mailto()
– Creates a standard HTML email link.
• url_title()
– Takes a string as input and creates a human-friendly URL string.
• redirect()
– Does a "header redirect" to the URI specified.
DEMO
QUESTIONS?

Weitere ähnliche Inhalte

Was ist angesagt?

Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Ahmed El-Arabawy
 
File Handling
File HandlingFile Handling
File HandlingWaqar Ali
 
InfiniFlux collector
InfiniFlux collectorInfiniFlux collector
InfiniFlux collectorInfiniFlux
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystemShay Cohen
 
05 File Handling Upload Mysql
05 File Handling Upload Mysql05 File Handling Upload Mysql
05 File Handling Upload MysqlGeshan Manandhar
 
Synapse india reviews on php website development
Synapse india reviews on php website developmentSynapse india reviews on php website development
Synapse india reviews on php website developmentsaritasingh19866
 
Php file upload, cookies & session
Php file upload, cookies & sessionPhp file upload, cookies & session
Php file upload, cookies & sessionJamshid Hashimi
 
Consuming Libraries with CMake
Consuming Libraries with CMakeConsuming Libraries with CMake
Consuming Libraries with CMakeRichard Thomson
 
Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring Ahmed El-Arabawy
 
Android - Data Storage
Android - Data StorageAndroid - Data Storage
Android - Data StorageMingHo Chang
 
Strings in c plus plus
Strings in c plus plusStrings in c plus plus
Strings in c plus plusNaveed Jamali
 
intro unix/linux 11
intro unix/linux 11intro unix/linux 11
intro unix/linux 11duquoi
 
Tutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginTutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginsearchbox-com
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorageKrazy Koder
 

Was ist angesagt? (20)

Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling
 
File Handling
File HandlingFile Handling
File Handling
 
InfiniFlux collector
InfiniFlux collectorInfiniFlux collector
InfiniFlux collector
 
rtwerewr
rtwerewrrtwerewr
rtwerewr
 
Php File Upload
Php File UploadPhp File Upload
Php File Upload
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystem
 
05 File Handling Upload Mysql
05 File Handling Upload Mysql05 File Handling Upload Mysql
05 File Handling Upload Mysql
 
Synapse india reviews on php website development
Synapse india reviews on php website developmentSynapse india reviews on php website development
Synapse india reviews on php website development
 
Php file upload, cookies & session
Php file upload, cookies & sessionPhp file upload, cookies & session
Php file upload, cookies & session
 
Consuming Libraries with CMake
Consuming Libraries with CMakeConsuming Libraries with CMake
Consuming Libraries with CMake
 
slide on DNS
slide on DNSslide on DNS
slide on DNS
 
Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring
 
Android - Data Storage
Android - Data StorageAndroid - Data Storage
Android - Data Storage
 
DNS Presentation
DNS PresentationDNS Presentation
DNS Presentation
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Strings in c plus plus
Strings in c plus plusStrings in c plus plus
Strings in c plus plus
 
Persistences
PersistencesPersistences
Persistences
 
intro unix/linux 11
intro unix/linux 11intro unix/linux 11
intro unix/linux 11
 
Tutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginTutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component plugin
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorage
 

Ähnlich wie CodeIgniter Helper Functions

Automating Content Import
Automating Content ImportAutomating Content Import
Automating Content ImportDavid Lippman
 
The Role of Atom/AtomPub in Digital Archive Services at The University of Tex...
The Role of Atom/AtomPub in Digital Archive Services at The University of Tex...The Role of Atom/AtomPub in Digital Archive Services at The University of Tex...
The Role of Atom/AtomPub in Digital Archive Services at The University of Tex...Peter Keane
 
Advance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-BAdvance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-BDr. Mazin Mohamed alkathiri
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6RUDDER
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6Jonathan Clarke
 
Hadoop 20111117
Hadoop 20111117Hadoop 20111117
Hadoop 20111117exsuns
 
07 darwino rest services
07   darwino rest services07   darwino rest services
07 darwino rest servicesdarwinodb
 
Postgresql Database Administration Basic - Day2
Postgresql  Database Administration Basic  - Day2Postgresql  Database Administration Basic  - Day2
Postgresql Database Administration Basic - Day2PoguttuezhiniVP
 
Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Ahmed El-Arabawy
 
php fundamental
php fundamentalphp fundamental
php fundamentalzalatarunk
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of phppooja bhandari
 
9780538745840 ppt ch05
9780538745840 ppt ch059780538745840 ppt ch05
9780538745840 ppt ch05Terry Yoast
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))Papu Kumar
 

Ähnlich wie CodeIgniter Helper Functions (20)

Helberg acl-final
Helberg acl-finalHelberg acl-final
Helberg acl-final
 
Files nts
Files ntsFiles nts
Files nts
 
Aggregate.pptx
Aggregate.pptxAggregate.pptx
Aggregate.pptx
 
Automating Content Import
Automating Content ImportAutomating Content Import
Automating Content Import
 
The Role of Atom/AtomPub in Digital Archive Services at The University of Tex...
The Role of Atom/AtomPub in Digital Archive Services at The University of Tex...The Role of Atom/AtomPub in Digital Archive Services at The University of Tex...
The Role of Atom/AtomPub in Digital Archive Services at The University of Tex...
 
Advance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-BAdvance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-B
 
Intro To C++ - Class #21: Files
Intro To C++ - Class #21: FilesIntro To C++ - Class #21: Files
Intro To C++ - Class #21: Files
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6
 
Hadoop 20111117
Hadoop 20111117Hadoop 20111117
Hadoop 20111117
 
Files and streams
Files and streamsFiles and streams
Files and streams
 
07 darwino rest services
07   darwino rest services07   darwino rest services
07 darwino rest services
 
Postgresql Database Administration Basic - Day2
Postgresql  Database Administration Basic  - Day2Postgresql  Database Administration Basic  - Day2
Postgresql Database Administration Basic - Day2
 
Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
php
phpphp
php
 
9780538745840 ppt ch05
9780538745840 ppt ch059780538745840 ppt ch05
9780538745840 ppt ch05
 
Jquery 2
Jquery 2Jquery 2
Jquery 2
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 

Mehr von Jamshid Hashimi

Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Jamshid Hashimi
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Jamshid Hashimi
 
Introduction to C# - Week 0
Introduction to C# - Week 0Introduction to C# - Week 0
Introduction to C# - Week 0Jamshid Hashimi
 
RIST - Research Institute for Science and Technology
RIST - Research Institute for Science and TechnologyRIST - Research Institute for Science and Technology
RIST - Research Institute for Science and TechnologyJamshid Hashimi
 
How Coding Can Make Your Life Better
How Coding Can Make Your Life BetterHow Coding Can Make Your Life Better
How Coding Can Make Your Life BetterJamshid Hashimi
 
Tips for Writing Better Code
Tips for Writing Better CodeTips for Writing Better Code
Tips for Writing Better CodeJamshid Hashimi
 
Launch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media IntegrationLaunch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media IntegrationJamshid Hashimi
 
Introduction to Blogging
Introduction to BloggingIntroduction to Blogging
Introduction to BloggingJamshid Hashimi
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to WordpressJamshid Hashimi
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class ReferenceJamshid Hashimi
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniterJamshid Hashimi
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterJamshid Hashimi
 

Mehr von Jamshid Hashimi (20)

Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1
 
Introduction to C# - Week 0
Introduction to C# - Week 0Introduction to C# - Week 0
Introduction to C# - Week 0
 
RIST - Research Institute for Science and Technology
RIST - Research Institute for Science and TechnologyRIST - Research Institute for Science and Technology
RIST - Research Institute for Science and Technology
 
How Coding Can Make Your Life Better
How Coding Can Make Your Life BetterHow Coding Can Make Your Life Better
How Coding Can Make Your Life Better
 
Mobile Vision
Mobile VisionMobile Vision
Mobile Vision
 
Tips for Writing Better Code
Tips for Writing Better CodeTips for Writing Better Code
Tips for Writing Better Code
 
Launch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media IntegrationLaunch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media Integration
 
Customizing Your Blog 2
Customizing Your Blog 2Customizing Your Blog 2
Customizing Your Blog 2
 
Customizing Your Blog 1
Customizing Your Blog 1Customizing Your Blog 1
Customizing Your Blog 1
 
Introduction to Blogging
Introduction to BloggingIntroduction to Blogging
Introduction to Blogging
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to Wordpress
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class Reference
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniter
 
CodeIgniter Practice
CodeIgniter PracticeCodeIgniter Practice
CodeIgniter Practice
 
CodeIgniter & MVC
CodeIgniter & MVCCodeIgniter & MVC
CodeIgniter & MVC
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
 
Exception & Database
Exception & DatabaseException & Database
Exception & Database
 
MySQL Record Operations
MySQL Record OperationsMySQL Record Operations
MySQL Record Operations
 
MySQL JOIN & UNION
MySQL JOIN & UNIONMySQL JOIN & UNION
MySQL JOIN & UNION
 

Kürzlich hochgeladen

Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 

Kürzlich hochgeladen (20)

20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 

CodeIgniter Helper Functions

  • 1. CodeIgniter Helper Functions Jamshid Hashimi Trainer, Cresco Solution http://www.jamshidhashimi.com jamshid@netlinks.af @jamshidhashimi ajamshidhashimi Afghanistan Workforce Development Program
  • 2. Agenda • Array Helper • Directory Helper • Download Helper • Email Helper • File Helper • Form Helper • HTML Helper • Text Helper • URL Helper
  • 3. Array Helper • The Array Helper file contains functions that assist in working with arrays. • $this->load->helper('array'); – Loading helper • element() – Lets you fetch an item from an array. • random_element() – Takes an array as input and returns a random element from it. • elements() – Lets you fetch a number of items from an array.
  • 4. Directory Helper • The Directory Helper file contains functions that assist in working with directories. • $this->load->helper('directory'); – Loading helper • directory_map('source directory') – This function reads the directory path specified in the first parameter and builds an array representation of it and all its contained files.
  • 5. Download Helper • The Download Helper lets you download data to your desktop. • $this->load->helper('download'); – Loading the helper • force_download('filename', 'data') – Generates server headers which force data to be downloaded to your desktop. Useful with file downloads. The first parameter is the name you want the downloaded file to be named, the second parameter is the file data.
  • 6. Email Helper • The Email Helper provides some assistive functions for working with Email. • $this->load->helper('email'); – Loading helper • valid_email('email') – Checks if an email is a correctly formatted email. Note that is doesn't actually prove the email will recieve mail, simply that it is a validly formed address.
  • 7. File Helper • The File Helper file contains functions that assist in working with files. • $this->load->helper('file'); – Loading helper • read_file('path') – Returns the data contained in the file specified in the path. • write_file('path', $data) – Writes data to the file specified in the path. If the file does not exist the function will create it. • delete_files('path') – Deletes ALL files contained in the supplied path. – If the second parameter is set to true, any directories contained within the supplied root path will be deleted as well.
  • 8. File Helper • get_filenames('path/to/directory/') – Takes a server path as input and returns an array containing the names of all files contained within it. • get_dir_file_info('path/to/directory/', $top_level _only = TRUE) – Reads the specified directory and builds an array containing the filenames, filesize, dates, and permissions. • get_file_info('path/to/file', $file_information) – Given a file and path, returns the name, path, size, date modified.
  • 9. File Helper • get_mime_by_extension('file') – Translates a file extension into a mime type based on config/mimes.php. • symbolic_permissions($perms) – Takes numeric permissions (such as is returned by fileperms() and returns standard symbolic notation of file permissions. • octal_permissions($perms) – Takes numeric permissions (such as is returned by fileperms() and returns a three character octal notation of file permissions.
  • 10. Form Helper • The Form Helper file contains functions that assist in working with forms. • $this->load->helper('form'); – Loading Helper • form_open() – Creates an opening form tag with a base URL built from your config preferences. – $attributes = array('class' => 'email', 'id' => 'myform'); – $hidden = array('username' => 'Joe', 'member_id' => '234'); • form_open_multipart() – This function is absolutely identical to the form_open() tag above except that it adds a multipart attribute, which is necessary if you would like to use the form to upload files with.
  • 11. Form Helper • form_hidden() – Lets you generate hidden input fields. • form_input() – Lets you generate a standard text input field. • form_password() • form_upload() • form_textarea() • form_dropdown() – Lets you create a standard drop-down field. • form_checkbox() – Lets you generate a checkbox field. • form_radio() • form_submit() • form_reset() • form_button() • form_close()
  • 12. HTML Helper • The HTML Helper file contains functions that assist in working with HTML. • $this->load->helper('html'); – Loading helper • br() – Generates line break tags (<br />) based on the number you submit. • heading() – Lets you create HTML <h1> tags. The first parameter will contain the data, the second the size of the heading. • img() – Lets you create HTML <img /> tags. The first parameter contains the image source. • nbs() – Generates non-breaking spaces (&nbsp;) based on the number you submit.
  • 13. Text Helper • The Text Helper file contains functions that assist in working with text. • $this->load->helper('text'); – Loading helper • word_limiter() – Truncates a string to the number of words specified. • character_limiter() – Truncates a string to the number of characters specified. • highlight_code() – Colorizes a string of code (PHP, HTML, etc.). • word_wrap() – Wraps text at the specified character count while maintaining complete words.
  • 14. URL Helper • The URL Helper file contains functions that assist in working with URLs. • $this->load->helper('url'); – Loading helper • site_url() – Returns your site URL, as specified in your config file. • base_url() – Returns your site base URL, as specified in your config file. • current_url() – Returns the full URL (including segments) of the page being currently viewed. • uri_string() – Returns the URI segments of any page that contains this function. • index_page() – Returns your site "index" page, as specified in your config file.
  • 15. URL Helper • anchor() – Creates a standard HTML anchor link based on your local site URL • anchor_popup() – Nearly identical to the anchor() function except that it opens the URL in a new window. • mailto() – Creates a standard HTML email link. • url_title() – Takes a string as input and creates a human-friendly URL string. • redirect() – Does a "header redirect" to the URI specified.
  • 16. DEMO