Example with soft-coding - php

What is difference between "hard-coding" and "soft-coding"?
Please explain it with an example of PHP code and MYSQL.
Thanks a lot.

I googled it.
Check this out: http://www.thoughtclusters.com/2007/08/hard-coding-and-soft-coding/

Related

json decode use variable as selector in php

I think ham to stupid for it :) I can't figured out whats wrong. I try to search at goole for the problem but think I don't use the correct phrases ... so I hope you can help me and my brain
Problem:
$mydata = $data['device']['26']['state']['1'];
Thats my code to readout json data. all is perfect. So my only problem is
['26']
this value is in an config file which is included, how can I use for expl.
$id
instead of ['26'] ... i want a littlest flexibility in this script but can't figured out how I do this.
thanks so much
$mydata = $data['device'][$id]['state']['1'];

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!

How to extract string from another string between the Nth and N+1th 'breakword' in php?

My example code is given below.
$a= "I think there are many people who can help in my difficulty. breakword Thank you in advance. brwakword If i got this solution I will be happy. Breakword I have already searched in google about it I did not get it's solution. Breakword If you have any link of solution please help me. breakword Thank you again!";
From the above string I want to get the sentence between 2nd and 3rd 'breakword' word.
It means I want to extract 'If i got this solution I will be happy.'.
If you have any solution please help me. Thank you in advance
You can split your string into smaller parts using explode() and get the "Nth" part of the array.
$sentences = explode('breakword', $a);
echo $sentences[2];
PHP > 5.4 will support this too :
echo explode('breakword', $a)[2];
a similar approach but intead of using explode you can also use preg_split
supports (PHP 4, PHP 5)
preg_split('/breakword/', $a);
for the second answer you can use
$dummy=array();
preg_match_all('/breakword/', $a,$dummy)

Decode an Encrypted PHP File Assistance

I have a file that I'm trying to decode but I'm not sure the best way to go about doing it. I've tried putting it through a few online tools but haven't had much luck...the code looks like this:
<?php
$zAkSoSavjFOn='jumbledcodeinhere';
$THkNltHSOjsXfQLzr=';))))aBSwinFbFxNm$(ireegf(rqbprq_46rfno(rgnysavmt(ynir';
$DzbOntpeGhMcan=strrev($THkNltHSOjsXfQLzr);
$WnJYuMUwKmRxBh=str_rot13($DzbOntpeGhMcan);
eval($WnJYuMUwKmRxBh);
?>
In all my playing I managed to extract the following with a php script:
eval(gzinflate(base64_decode(strrev($zAkSoSavjFOn))));
Could someone point me in the right direction on going about this process? Any help would be appreciated. :)
The "jumbled code" is gzipped, base64-encoded, reversed PHP code that is almost certainly malicious.
Replace eval with echo and see what it gives you, that's what the code that is trying to run is.

Where is 'tsrm_ls' in PHP sources?

I'm coding an extension to change the way PHP handles errors. Where is 'tsrm_ls' declared? I can't find it.
P.S. I think it is a 'typedef'
Edit: Still can't find it. Is it declared locally? I think it is used in the EG macro.
You might find this explanation quite helpful:
http://blog.golemon.com/2006/06/what-heck-is-tsrmlscc-anyway.html
Figured it out.
TSRMLS_FETCH();
Have to run it before calling any of those macros.
http://lxr.php.net/search?q=tsrm_ls&project=PHP_5_3&defs=&refs=&path=&hist=
From what I can gather it might be in php_apache.c

Categories