Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7024979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:54:50+00:00 2026-05-27T23:54:50+00:00

I am using CodeIgniter. Recently, I read a PHP book and saw some functions

  • 0

I am using CodeIgniter.

Recently, I read a PHP book and saw some functions to escape output to server to database using

*_escape_string()

and from server to browser using:

htmlentities()
htmlspecialchars()

In my Codeigniter application, how are these functions handled? Is it internally handled by the framework, or do I have to manually handle it?

In Ccodeigniter form validation I have seen xss_clean

$this->form_validation->set_rules('password', 'Password', 'required|xss_clean|min_length[6]|matches[confirmpassword]' );

Is xss_clean for preventing cross site scripting, or does it deal with the above I have mentioned?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:54:51+00:00Added an answer on May 27, 2026 at 11:54 pm

    If you’re using the Active Record class, you generally don’t need to escape anything you send to your database – it’s done automatically:

    http://codeigniter.com/user_guide/database/active_record.html

    "It also allows for safer queries, since the values are escaped automatically by the system."

    Manual escaping seems to be becoming a thing of the past, as most people are using PDO now for database interactions, using paramterized queries with placeholders instead of mashing SQL strings together. CI still uses the mysql_* functions internally though.

    CI’s xss_clean() is, in my opinion, more of a failsafe for those of us who don’t know how and when to escape data properly. You normally don’t need it. It’s been the target of criticism both for it’s slow, aggressive approach to sanitizing data, as well as for just "not being good enough".

    For escaping HTML output, in most cases htmlspecialchars() is all you need, but you can use the xss_clean() function any time. I don’t suggest using it as a form validation rule because it will corrupt your input, inserting [removed] wherever it found something "naughty" in the original string. Instead, you can just call it manually to clean your output.

    Summary:

    • Database: CI will (usually) escape the strings you pass to the Active Record class.
      See the user guide for details: http://codeigniter.com/user_guide/database/queries.html

    • HTML output: You need to escape HTML output yourself with htmlspecialchars() or use CI’s html_escape() function (as of 2.1.0). This is not done automatically because there’s no way to know the context in which you are using the data.

    • xss_clean() – If you know what you’re doing, you shouldn’t need it. Better to use on output than input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using CodeIgniter to pass some parameters to my PHP page through $_POST
Using Codeigniter, any numeric data returned from my MySQL database is returned as strings.
i recently start using CodeIgniter as PHP MVC FrameWork , before CodeIgniter, i was
I have recently started using the CodeIgniter framework for my PHP development. I was
Ive recently started using CodeIgniter as I was searching for a very lightweight framework
I've been using CodeIgniter for some time, and I liked it a lot. It
I'm using CodeIgniter (a PHP framework) to build an app, and I have an
I'm using CodeIgniter (because it's awesome) and I have something like: <?php echo anchor(/,
I'm using CodeIgniter with CodeIgniter sessions that are stored in a MySQL database. I
I've starting using Codeigniter for a project recently (few months ago) but its getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.