0

I want to convert string to string which are url friendly

In my none Zend Framework 2 project is just use urlencode($valueContainingString);

Now i'm building an application with Zend Framework 2, now I was wondering if there is any better way to do this.

I did some research and I looked at constrains for the route but it's not working for me.

1
  • is urlencode() not working for you? I use rawurlencode() in ZF2 project which should work the same and url friendly. Commented Dec 12, 2013 at 5:31

1 Answer 1

2

Have a look at the \Zend\Escaper classes - there you have plenty of escaping functions for most common use cases.

http://framework.zend.com/manual/2.2/en/modules/zend.escaper.introduction.html

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, that will do trick for now. It's not perfect for SEO but that's something for later
SEOing your URLs is not part of escaping, but a step before escaping. You'd usually reduce the number of allowed characters, lowercase everything and replace spaces with dashes. But this step is part of your URL-creation logic, and not part of escaping. Even if you did SEO your URLs, you'd have to escape.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.