hex html value as php - php

simply put i want to know why the first echo is giving back \x02 and the second echo doesn't give back something when it is exactly the same. why is the first echo not recognized as hex?
$test = "02";
echo "\x".$test;
echo "\x02";
hope someone can solve this. has been bothering me for a while

The answer is what was posted in my other post about this subject.
Link to question:create nameserver hex header
credits go to glglgl :)
sorry for the trouble

Related

How to deal with 'µg' in PHP?

So I am having problems with the symbol µg in PHP. The symbol is inside an array of data but I can't seem to match it with the following:
if($value == 'µg') {
echo 'blah';
}
Does anyone happen to have a work around for this? I'm assuming PHP saves it as a different type then what I am comparing it to because it never echo's the 'blah' above. I have searched around for a while now and cannot find anything to help me. Thanks!
Okay so even with the help of some people I haven't found the answer.
The best I came up with that actually works is:
substr('µg', 1,7) == 'micro;g'
That's the only way I found out how to parse the data. If you put the & in front of the micro; you get the µ. A dirty fix but if anyone has a way around please let me know. Thanks!

string name out of vlaue of another string php

in PHP I have the following case:
<?php $anz1='3';$i='1';echo $anz.$i;?>
I don't know how to echo $anz1 with the help of $i. I must do it this way, this is just an easy case, I need it for loops where it echos every $anz
Thanks in advance
I hope I could write it understable for you, my english is not the very best.
Maybe this is what you're looking for:
$anz1='3';
$i='1';
echo ${'anz'.$i};
Output:
3

How to use regex in PHP to get int after slash in string

I've tried to create a code in PHP that gets the topic id after the forward slash in a given string. However the problem i'm having is that its returning nothing, how can i make it return the int?
echo preg_match('/([^/]+)/', 'Learning-English/478', $discussion_id);
echo $discussion_id;
This is for an online forum, thank you for your help; it's much appreciated. If you need ay more information please don't hesitate to leave a comment.
preg_match("#/(\d+)$#", 'Learning-English/478', $discussion_id);
That would work for you.
To print the id(matched number); you need to echo $discussion_id[1].
Here is a working link.
For the newer strings, you wouldn't be needing the string end match($). Thus, the regex will be:
preg_match("#/(\d+)#", 'Looking-for-Pen-Pals/1161&t=viewDiscussion', $discussion_id);
echo $discussion_id[1];
you could just use explode() like this:
$arr = explode('/',$string);
$discussion_id = $arr[count($arr)-1];
this will split your string and then get you the last part.

PHP call array value

First I have these variables:
$asd=$current[0]->icon['data']; // -it will print /ig/images/weather/mostly_cloudy.gif
$icons["/ig/images/weather/rain.gif"][0]; // it will print rain.gif
I want to see rain.gif output. I'm trying to do this.
echo $icons[$asd][0]; // I will get error.
I want to get this output with variables.
$icons["/ig/images/weather/rain.gif"][0]; // it will print rain.gif
Is the code wrong?
echo $icons[$asd][0];
Please help.
thanks evryone. sorry for my english.
how can I do this.
I think you're looking for basename.
echo basename('/ig/images/weather/mostly_cloudy.gif'); // output: mostly_cloudy.gif');
echo basename('/ig/images/weather/rain.gif'); // output: rain.gif
Assuming that $asd (in your example) is the path to the image and you're just looking for the file name portion).
Though your question is not 100% clear.

How to read this php code?

How to decode this string in php?
$x = "h\164tp\163\072\057\057\x70r\157\x64\x75\x63t-\x73\x65a\x72\143\150\056\x61\160i\x2e\x63\x6a\x2ec\x6f\x6d\057v\062/\160\x72\157\x64\165\x63t\x2ds\x65\141\162\143\x68\x3f";
It looks like a regex URL, but how to read what it is?
Thanks.
just echo it out.
<?
$x = "h\164tp\163\072\057\057\x70r\157\x64\x75\x63t-\x73\x65a\x72\143\150\056\x61\160i\x2e\x63\x6a\x2ec\x6f\x6d\057v\062/\160\x72\157\x64\165\x63t\x2ds\x65\141\162\143\x68\x3f";
echo $x;
It outputs:
https://product-search.api.cj.com/v2/product-search?
Print it!
% cat test.php
#!/usr/bin/env php
<?php
$x = "h\164tp\163\072\057\057\x70r\157\x64\x75\x63t-\x73\x65a\x72\143\150\056\x61\160i\x2e\x63\x6a\x2ec\x6f\x6d\057v\062/\160\x72\157\x64\165\x63t\x2ds\x65\141\162\143\x68\x3f";
print $x;
?>
% ./test.php
https://product-search.api.cj.com/v2/product-search?
It is actually a string with some characters specified in hexadecimal and octal notation. Just echo it.
just print it, its a url
https://product-search.api.cj.com/v2/product-search?
Well, I created a PHP page as follows:
<?php
$x = "h\164tp\163\072\057\057\x70r\157\x64\x75\x63t-\x73\x65a\x72\143\150\056\x61\160i\x2e\x63\x6a\x2ec\x6f\x6d\057v\062/\160\x72\157\x64\165\x63t\x2ds\x65\141\162\143\x68\x3f";
print $x;
?>
and ran it.
And I got the following:
https://product-search.api.cj.com/v2/product-search?
Which means nothing to me, except that cj.com is part of Commission Junction, which is an online advertising network.
It's been deliberately obfuscated, so clearly the person who wrote it intended that you didn't notice it or understand it, and would leave it alone. I don't know the context of the question, why you're asking about it, but my guess would be that you've been hacked and someone has inserted this code (and more) into your site.
If that's the case, their aim would clearly be to gain some advertising revenue by freeloading on your site. Not particularly malicious as hacks go, but not something you'd want to be happening (especially if you don't know what kind of ads would be shown).
Simple:
utf8_decode();
http://www.php.net/manual/en/function.utf8-decode.php

Categories