0

I have some site written on php5 using most ancient CodeIgniter version.
I have config:

$config['charset'] = 'windows-1251';

At some place, I have 2 string values.

  1. $this->uri->segment(2)
  2. "{shortname}" . ".html"

I want compare them, and do something if they are equals.
But I get into hell...

Now, I have some code in some view:

<?=(strcmp($this->uri->segment(2), "{shortname}" . ".html") == 0) ?
        'test' :
        'notest' ?><br/>
<?=mb_detect_encoding($this->uri->segment(2))?><br/>
<?=mb_detect_encoding("{shortname}" . ".html")?><br/>
<?=base64_encode(mb_convert_encoding($this->uri->segment(2), 'UTF-8'))?><br/>
<?=base64_encode(mb_convert_encoding("{shortname}" . ".html", 'UTF-8'))?><br/>
<?=$this->uri->segment(2)?><br/>
<?="{shortname}" . ".html"?><br/>

As a result I have:

notest
ASCII
ASCII
cml6b2dyYWZpamEtdGlyYXpoaXJvdmFuaWUuaHRtbA==
e3Nob3J0bmFtZX0uaHRtbA==
rizografija-tirazhirovanie.html
rizografija-tirazhirovanie.html

How I need encode/decode/compare for it will work?

1 Answer 1

3

base64_decode("e3Nob3J0bmFtZX0uaHRtbA==") = {shortname}.html

Your {shortname} placeholder is not replaced. I'm not use CodeIgniter, but maybe you like to use {$shortname} ? (inserts $shortname variable value)

Example:

echo strcmp($this->uri->segment(2), "$shortname.html") == 0) ? 'test' : 'notest';
Sign up to request clarification or add additional context in comments.

1 Comment

Yes! It is the reason. It replaced only if I use it directly: <?={shortname}?>. But if I pass it as an argument, it not replacing... I put the condition in controller. Thank you very much!

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.