Sponsored Content
Top Forums Shell Programming and Scripting PHP: declared variables, strlen vs isset Post 302976543 by crimso on Thursday 30th of June 2016 01:45:07 PM
Old 06-30-2016
yes, i just left that bit out since i would let you guys assume i had that part covered and to limit how big the post got.

Code:
<?php
#!/usr/bin/php -q

if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD'])  || isset($_SERVER['REMOTE_ADDR'])) {
        die("<br><strong>This script is only meant to run at the command line.</strong>");
}

$no_http_headers = true;

chdir(dirname(__FILE__));
chdir("../../");
include("./include/global.php");
include_once("./lib/xml.php");

$parms = $_SERVER["argv"];
array_shift($parms);

global $debug;

$debug   = FALSE;
$server  = "";
$host    = "";
$port    = "";
$path    = "";
$timeout = 20;

foreach($parms as $parameter) {
        @list($arg, $value) = @explode("=", $parameter);

        switch ($arg) {
        case "-D":
        case "--debug":
                $debug = TRUE;
                break;
        case "-S":
        case "--server":
                $server = $value;
                break;
        case "-H":
        case "--host":
                $host = $value;
                break;
        case "-O":
        case "--port":
                $port = $value;
                break;
        case "-P":
        case "--path":
                $path = $value;
                break;
        case "-T":
        case "--timeout":
                $timeout = $value;
                break;
        case "-v":
        case "-V":
        case "--version":
        case "--help":
        case "-h":
        case "-H":
                display_help();
                exit;
        default:
                print "ERROR: Invalid Parameter " . $parameter . "\n\n";
                display_help();
                exit;
        }
}

 

10 More Discussions You Might Find Interesting

1. Programming

Problems with Strlen

hello, i have a problem with strlen. I have written this: for(y=13,z=0; cInBuf!=' ';y++) { cBuf=cInBuf; z++; } len = strlen(cBuf); out=len/2; fprintf(outfile,"F%i",out); If strlen is e.g. 22, it write F22. I want to write F2F2. How can i do this?... (5 Replies)
Discussion started by: ACeD
5 Replies

2. Shell Programming and Scripting

Problem with the strlen function in ksh

Hello, Just a little problem with the ksh function : strlen I want to use this function in this little ksh program : while read line ; do TOTO=$line TOTONB=strlen($TOTO) echo $TOTONB (3 Replies)
Discussion started by: steiner
3 Replies

3. Shell Programming and Scripting

accessing variables declared in another perl script

Hi all, I have a perl script which declares two variables and calls another perl script which accesses those variables. But I am unable to access the variables in the called script. My script is as follows: my $ENV{a}="20"; system("perl called.pl"); and my called.pl contains: print... (3 Replies)
Discussion started by: gurukottur
3 Replies

4. Programming

'strlen' of a constant string

In a declaration, I have: const char comment_begin = "<!--"; const char comment_end = "-->"; const int comment_begin_len = strlen(comment_begin); const int comment_end_len = strlen(comment_end); When I compile, I get the warnings: emhttpc.c:64: warning: initializer element is not... (10 Replies)
Discussion started by: cleopard
10 Replies

5. Programming

pointer arithmetic vs. strlen() & strnlen()?

I have been getting some flack recently for my use of strlen() and strnlen(). Honestly I have always just taken their functionality for granted as being the easiest way of getting the length of a string. Is it really so much better to do pointer arithmetic? What am I gaining besides more... (3 Replies)
Discussion started by: jjinno
3 Replies

6. Shell Programming and Scripting

isset() PHP function in cgi bash scripts

Hi! Some minutes ago I've posted a question related with sed regexps because I need to catch information sended with forms with GET action. This is the post: https://www.unix.com/shell-programming-scripting/127800-regular-expression-sed.html But now I have a new question. Does cgi scripts have... (0 Replies)
Discussion started by: GagleKas
0 Replies

7. Programming

strlen for UTF-8

My OS (Debian) and gcc use the UTF-8 locale. This code says that the char size is 1 byte but the size of 'a' is really 4 bytes. int main(void) { setlocale(LC_ALL, "en_US.UTF-8"); printf("Char size: %i\nSize of char 'a': %i\nSize of Euro sign '€': %i\nLength of Euro sign: %i\n",... (8 Replies)
Discussion started by: cyler
8 Replies

8. AIX

`pthread_rwlock_t' was not declared in this scope

Hello All, I am getting this error while compiling my application on IBM AIX 5.3. As I tried to define _XOPEN_SOURCE=500 in makefile, that didn't work. Please help us to resolve the error. (0 Replies)
Discussion started by: mustus
0 Replies

9. Shell Programming and Scripting

Help in separating variables declared in the main function

Hi! I've a C program as shown below.. The line numbers and the statements of the program are separated by a space.. 1 #include<stdio.h> 2 char a,b,c; 3 float x,y,z; 4 int main() 5 { 6 int d,e,f; 7 // further declarations 8 // further declarations 9 /* body*/ 10 } 11 void fun1() 12... (1 Reply)
Discussion started by: abk07
1 Replies

10. Programming

Segment fault related to strlen.S

Hello, This function was copied into my code, which was compiled without error/warning, but when executed there is always Segmentation fault at the end after the output (which seems correct!): void get_hashes(unsigned int hash, unsigned char *in) { unsigned char *str = in; int pos =... (7 Replies)
Discussion started by: yifangt
7 Replies
ARRAY_KEY_EXISTS(3)							 1						       ARRAY_KEY_EXISTS(3)

array_key_exists - Checks if the given key or index exists in the array

SYNOPSIS
bool array_key_exists (mixed $key, array $array) DESCRIPTION
array_key_exists(3) returns TRUE if the given $key is set in the array. $key can be any value possible for an array index. PARAMETERS
o $key - Value to check. o $array - An array with keys to check. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 array_key_exists(3) example <?php $search_array = array('first' => 1, 'second' => 4); if (array_key_exists('first', $search_array)) { echo "The 'first' element is in the array"; } ?> Example #2 array_key_exists(3) vs isset(3) isset(3) does not return TRUE for array keys that correspond to a NULL value, while array_key_exists(3) does. <?php $search_array = array('first' => null, 'second' => 4); // returns false isset($search_array['first']); // returns true array_key_exists('first', $search_array); ?> NOTES
Note For backward compatibility, the following deprecated alias may be used: key_exists(3) Note For backward compatibility reasons, array_key_exists(3) will also return TRUE if $key is a property defined within an object given as $array. This behaviour should not be relied upon, and care should be taken to ensure that $array is an array. To check whether a property exists in an object, use property_exists(3). SEE ALSO
isset(3), array_keys(3), in_array(3), property_exists(3). PHP Documentation Group ARRAY_KEY_EXISTS(3)
All times are GMT -4. The time now is 10:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy