SlideShare a Scribd company logo
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?

More Related Content

What's hot (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
Ahmed El-Arabawy
 
File Handling
File HandlingFile Handling
File Handling
Waqar Ali
 
InfiniFlux collector
InfiniFlux collectorInfiniFlux collector
InfiniFlux collector
InfiniFlux
 
rtwerewr
rtwerewrrtwerewr
rtwerewr
esolinhighered
 
Php File Upload
Php File UploadPhp File Upload
Php File Upload
Hiroaki Kawai
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystem
Shay Cohen
 
05 File Handling Upload Mysql
05 File Handling Upload Mysql05 File Handling Upload Mysql
05 File Handling Upload Mysql
Geshan 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 development
saritasingh19866
 
Php file upload, cookies & session
Php file upload, cookies & sessionPhp file upload, cookies & session
Php file upload, cookies & session
Jamshid Hashimi
 
Consuming Libraries with CMake
Consuming Libraries with CMakeConsuming Libraries with CMake
Consuming Libraries with CMake
Richard Thomson
 
slide on DNS
slide on DNSslide on DNS
slide on DNS
webhostingguy
 
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 Storage
MingHo Chang
 
DNS Presentation
DNS PresentationDNS Presentation
DNS Presentation
Shubham Srivastava
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
Dr. Volkan OBAN
 
Strings in c plus plus
Strings in c plus plusStrings in c plus plus
Strings in c plus plus
Naveed Jamali
 
Persistences
PersistencesPersistences
Persistences
Training Guide
 
intro unix/linux 11
intro unix/linux 11intro unix/linux 11
intro unix/linux 11
duquoi
 
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
searchbox-com
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorage
Krazy Koder
 
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 Handling
Waqar Ali
 
InfiniFlux collector
InfiniFlux collectorInfiniFlux collector
InfiniFlux collector
InfiniFlux
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystem
Shay Cohen
 
05 File Handling Upload Mysql
05 File Handling Upload Mysql05 File Handling Upload Mysql
05 File Handling Upload Mysql
Geshan 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 development
saritasingh19866
 
Php file upload, cookies & session
Php file upload, cookies & sessionPhp file upload, cookies & session
Php file upload, cookies & session
Jamshid Hashimi
 
Consuming Libraries with CMake
Consuming Libraries with CMakeConsuming Libraries with CMake
Consuming Libraries with CMake
Richard 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 Storage
MingHo Chang
 
Strings in c plus plus
Strings in c plus plusStrings in c plus plus
Strings in c plus plus
Naveed Jamali
 
intro unix/linux 11
intro unix/linux 11intro unix/linux 11
intro unix/linux 11
duquoi
 
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
searchbox-com
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorage
Krazy Koder
 

Similar to CodeIgniter Helper Functions (20)

Helberg acl-final
Helberg acl-finalHelberg acl-final
Helberg acl-final
Clay Helberg
 
Files nts
Files ntsFiles nts
Files nts
kalyani66
 
Data Handling in R language basic concepts.pptx
Data Handling in R language basic concepts.pptxData Handling in R language basic concepts.pptx
Data Handling in R language basic concepts.pptx
gameyug28
 
Aggregate.pptx
Aggregate.pptxAggregate.pptx
Aggregate.pptx
Ramakrishna Reddy Bijjam
 
01 file handling for class use class pptx
01 file handling for class use class pptx01 file handling for class use class pptx
01 file handling for class use class pptx
PreeTVithule1
 
Automating Content Import
Automating Content ImportAutomating Content Import
Automating Content Import
David 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-B
Dr. Mazin Mohamed alkathiri
 
File Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handlingFile Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handling
abdulsamadbrohi461
 
Intro To C++ - Class #21: Files
Intro To C++ - Class #21: FilesIntro To C++ - Class #21: Files
Intro To C++ - Class #21: Files
Blue Elephant Consulting
 
File Handling Btech computer science and engineering ppt
File Handling Btech computer science and engineering pptFile Handling Btech computer science and engineering ppt
File Handling Btech computer science and engineering ppt
pinuadarsh04
 
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
RUDDER
 
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
Jonathan Clarke
 
Hadoop 20111117
Hadoop 20111117Hadoop 20111117
Hadoop 20111117
exsuns
 
Files and streams
Files and streamsFiles and streams
Files and streams
Pranali Chaudhari
 
Data analystics with R module 3 cseds vtu
Data analystics with R module 3 cseds vtuData analystics with R module 3 cseds vtu
Data analystics with R module 3 cseds vtu
LalithauLali
 
07 darwino rest services
07   darwino rest services07   darwino rest services
07 darwino rest services
darwinodb
 
Postgresql Database Administration Basic - Day2
Postgresql  Database Administration Basic  - Day2Postgresql  Database Administration Basic  - Day2
Postgresql Database Administration Basic - Day2
PoguttuezhiniVP
 
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
phpphp
php
Ramki Kv
 
Data Handling in R language basic concepts.pptx
Data Handling in R language basic concepts.pptxData Handling in R language basic concepts.pptx
Data Handling in R language basic concepts.pptx
gameyug28
 
01 file handling for class use class pptx
01 file handling for class use class pptx01 file handling for class use class pptx
01 file handling for class use class pptx
PreeTVithule1
 
Automating Content Import
Automating Content ImportAutomating Content Import
Automating Content Import
David 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-B
Dr. Mazin Mohamed alkathiri
 
File Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handlingFile Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handling
abdulsamadbrohi461
 
File Handling Btech computer science and engineering ppt
File Handling Btech computer science and engineering pptFile Handling Btech computer science and engineering ppt
File Handling Btech computer science and engineering ppt
pinuadarsh04
 
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
RUDDER
 
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
Jonathan Clarke
 
Hadoop 20111117
Hadoop 20111117Hadoop 20111117
Hadoop 20111117
exsuns
 
Data analystics with R module 3 cseds vtu
Data analystics with R module 3 cseds vtuData analystics with R module 3 cseds vtu
Data analystics with R module 3 cseds vtu
LalithauLali
 
07 darwino rest services
07   darwino rest services07   darwino rest services
07 darwino rest services
darwinodb
 
Postgresql Database Administration Basic - Day2
Postgresql  Database Administration Basic  - Day2Postgresql  Database Administration Basic  - Day2
Postgresql Database Administration Basic - Day2
PoguttuezhiniVP
 
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
 
Ad

More from 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
Jamshid 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 1
Jamshid Hashimi
 
Introduction to C# - Week 0
Introduction to C# - Week 0Introduction to C# - Week 0
Introduction to C# - Week 0
Jamshid 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 Technology
Jamshid 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 Better
Jamshid Hashimi
 
Mobile Vision
Mobile VisionMobile Vision
Mobile Vision
Jamshid Hashimi
 
Tips for Writing Better Code
Tips for Writing Better CodeTips for Writing Better Code
Tips for Writing Better Code
Jamshid 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 Integration
Jamshid Hashimi
 
Customizing Your Blog 2
Customizing Your Blog 2Customizing Your Blog 2
Customizing Your Blog 2
Jamshid Hashimi
 
Customizing Your Blog 1
Customizing Your Blog 1Customizing Your Blog 1
Customizing Your Blog 1
Jamshid Hashimi
 
Introduction to Blogging
Introduction to BloggingIntroduction to Blogging
Introduction to Blogging
Jamshid Hashimi
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to Wordpress
Jamshid Hashimi
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class Reference
Jamshid Hashimi
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniter
Jamshid Hashimi
 
CodeIgniter Practice
CodeIgniter PracticeCodeIgniter Practice
CodeIgniter Practice
Jamshid Hashimi
 
CodeIgniter & MVC
CodeIgniter & MVCCodeIgniter & MVC
CodeIgniter & MVC
Jamshid Hashimi
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
Jamshid Hashimi
 
Exception & Database
Exception & DatabaseException & Database
Exception & Database
Jamshid Hashimi
 
MySQL Record Operations
MySQL Record OperationsMySQL Record Operations
MySQL Record Operations
Jamshid Hashimi
 
MySQL JOIN & UNION
MySQL JOIN & UNIONMySQL JOIN & UNION
MySQL JOIN & UNION
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 2
Jamshid 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 1
Jamshid Hashimi
 
Introduction to C# - Week 0
Introduction to C# - Week 0Introduction to C# - Week 0
Introduction to C# - Week 0
Jamshid 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 Technology
Jamshid 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 Better
Jamshid Hashimi
 
Tips for Writing Better Code
Tips for Writing Better CodeTips for Writing Better Code
Tips for Writing Better Code
Jamshid 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 Integration
Jamshid Hashimi
 
Introduction to Blogging
Introduction to BloggingIntroduction to Blogging
Introduction to Blogging
Jamshid Hashimi
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to Wordpress
Jamshid Hashimi
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class Reference
Jamshid Hashimi
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniter
Jamshid Hashimi
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
Jamshid Hashimi
 
Ad

Recently uploaded (20)

6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Compliance-as-a-Service document pdf text
Compliance-as-a-Service document pdf textCompliance-as-a-Service document pdf text
Compliance-as-a-Service document pdf text
Earthling security
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
The case for on-premises AI
The case for on-premises AIThe case for on-premises AI
The case for on-premises AI
Principled Technologies
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
Top 25 AI Coding Agents for Vibe Coders to Use in 2025.pdf
Top 25 AI Coding Agents for Vibe Coders to Use in 2025.pdfTop 25 AI Coding Agents for Vibe Coders to Use in 2025.pdf
Top 25 AI Coding Agents for Vibe Coders to Use in 2025.pdf
SOFTTECHHUB
 
Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)
Brian Ahier
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
soulmaite review - Find Real AI soulmate review
soulmaite review - Find Real AI soulmate reviewsoulmaite review - Find Real AI soulmate review
soulmaite review - Find Real AI soulmate review
Soulmaite
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Scott M. Graffius
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Compliance-as-a-Service document pdf text
Compliance-as-a-Service document pdf textCompliance-as-a-Service document pdf text
Compliance-as-a-Service document pdf text
Earthling security
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
Top 25 AI Coding Agents for Vibe Coders to Use in 2025.pdf
Top 25 AI Coding Agents for Vibe Coders to Use in 2025.pdfTop 25 AI Coding Agents for Vibe Coders to Use in 2025.pdf
Top 25 AI Coding Agents for Vibe Coders to Use in 2025.pdf
SOFTTECHHUB
 
Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)
Brian Ahier
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
soulmaite review - Find Real AI soulmate review
soulmaite review - Find Real AI soulmate reviewsoulmaite review - Find Real AI soulmate review
soulmaite review - Find Real AI soulmate review
Soulmaite
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Scott M. Graffius
 

CodeIgniter Helper Functions

  • 1. CodeIgniter Helper Functions Jamshid Hashimi Trainer, Cresco Solution http://www.jamshidhashimi.com [email protected] @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