TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Saving Strings to not be edited (http://www.talkphp.com/general/2416-saving-strings-not-edited.html)

Orc 03-04-2008 01:43 PM

Saving Strings to not be edited
 
I want to figure out how to save strings which cannot be edited any longer. How would I do this without files? Meaning an irreversible string or variable.

Wildhoney 03-04-2008 02:04 PM

Could you elaborate, please. I don't understand.

Orc 03-04-2008 02:06 PM

Quote:

Originally Posted by Wildhoney (Post 11967)
Could you elaborate, please. I don't understand.

A variable that once its assigned, it cannot be modified. How would I do this?

StevenF 03-04-2008 03:58 PM

Quote:

Originally Posted by Orc (Post 11968)
A variable that once its assigned, it cannot be modified. How would I do this?

Forgive me, I'm fairly new to this - I don't understand what you mean, can't it only be modified by you? (or the person who has the script).

Alan @ CIT 03-04-2008 05:16 PM

I'm also confused :-) Is the variable being assigned in your script or by a user? Is it being stored in a database or does it only exist in the PHP script?

Alan

xenon 03-04-2008 08:03 PM

I think he needs constants:

PHP Code:

define('SOME_VAR''abcde');

SOME_VAR 'test'// fatal error 


ReSpawN 03-04-2008 08:58 PM

Indeed Xenon, or
PHP Code:

define (_TALK_PHP'TalkPHP');
if ( 
defined _TALK_PHP ) ) { echo 'Defined'; } 

Make a function for defining those things I guess. There is a better way tho.
PHP Code:

    
    $lang 
= array();
    
$lang[] = 'talkphp';
    
$lang[] = 'talkPHP';
    
    function 
pushWord($word) {
        global 
$lang;
        if ( !
in_array($word$lang) ) {
            
array_push($lang$word);
            echo 
'Added to the list!';
        } else {
            echo 
$word.' is already in the array!';
        }
    }
    
    
pushWord('talkPHP');
    
    echo 
'<br><br>Your content of the $lang array:<br><br>';
    
    foreach (
$lang as $key => $value) {
        echo 
$value.'<br>';
    } 


Orc 03-05-2008 12:59 PM

Perfect, thanks Xenon and Respawn!


All times are GMT. The time now is 09:26 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0