Welcome Guest, Not a member yet? Register   Sign In
$this->uri->segment(3) return an object or a string?
#1

[eluser]huaxz1986[/eluser]
This is OK:
Code:
<?=form_open("collection/modf_col/".$this->uri->segment(3))?>
This work wrong:
Code:
<?=form_open("collection/modf_col/$this->uri->segment(3))"?>
It says that :
Quote:A PHP Error was encountered

Severity: 4096

Message: Object of class CI_URI could not be converted to string

Filename: collections/view_modf.php

Line Number: 3
What is "$this->uri->segment(3) " returns?
#2

[eluser]InsiteFX[/eluser]
What does the Error message say?

Object!
#3

[eluser]Phil Sturgeon[/eluser]
You are trying to embed an object method call into a double quote string without the correct parenthesis or concatentation.

Code:
<?=form_open("collection/modf_col/".$this->uri->segment(3)) ?> 
#4

[eluser]huaxz1986[/eluser]
Then,what is the correct usage of "$this->uri->segment(3)"?
I want to get the third segment of uri as an argument.

[quote author="Phil Sturgeon" date="1328813422"]You are trying to embed an object method call into a double quote string without the correct parenthesis or concatentation.

Code:
<?=form_open("collection/modf_col/".$this->uri->segment(3)) ?> 
[/quote]
#5

[eluser]CroNiX[/eluser]
It returns a string, or FALSE if the segment doesn't exist.
#6

[eluser]Phil Sturgeon[/eluser]
[quote author="huaxz1986" date="1328847540"]Then,what is the correct usage of "$this->uri->segment(3)"?
I want to get the third segment of uri as an argument.[/quote]

The code I pasted is the code you want to use, that would be why I posted it. Wrapping method calls in a string is not only pointless but invalid...
#7

[eluser]giriayoga[/eluser]
thank's for your example.... Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB