Jump to content
php.lv forumi

besis

Reģistrētie lietotāji
  • Content Count

    8
  • Joined

  • Last visited

About besis

  • Rank
    Māceklis
  1. skaidrojums: ASM kodu nesaam operatoreem, kas ievadiija kodu kautkaadaas mistiskaas mehaaniskaas uzpariktees, tad taas uzpariktes izdeva aaraa sacaurumotas perfokartes kuras nesaam uz skaitljoshanas centru ievadiishanai mainfreimaa. Bija arii taada lieta kaa perfolentes , taas gan nenaacaas lietot.
  2. codez, jaa php int tipa mainiigajam $a , $a++ ir tas pats kas ieksh c , a++ benchmarku uztaisiishu protams (un taas nebuus tikai 1M iteraacijas), diemzheel pagaidaam nav laika ar taadiem siikumiem kraameeties, jo ljoti daudz darba. Par biksinjaas churaashanu, protams nolaidi greizi. Domaaju, ka pats veel maates pienu suuci , kad es nesu perfokartes ar ASM kodu uz auseklja ielu, piebilde - IBM PC tad veel nebija, visu dariijaam uz mainfreimiem, diskeshu arii nebija, ievaddati tikai caur perfokarteem, hehe, tas tik bija laiks... Ever wonder how PHP can have so many different data types for its variables? PHP is regarded as a loosely typed language, and variables can change their data type easily. In fact, PHP can have eight different types: integer numbers (stored as longs in c) floating point numbers (stored as doubles in c) strings (stored as a char array in c) Booleans (stored as 0 or 1 as longs in c) Arrays (stored as HashTable struct in c) Objects (stored as zend_object_value in c) Resources (stored as zend_object_value in c) [references functions or external PHP resources] Null (nothing is stored, only type is set to null type)
  3. "Koda dievs", jociigais cilveek Tu man centiisies ieskaidrot ka mashiinkoda operaacija - integer inkrements ir tikai 20 reizes aatraaks par rindas skaneeshanas un sastaavdalju paarsuutiishanas operaacijaam , dzekinj nokompilee uz c un paskaties kodu, varbuut tad tev naaks sapraats maajaas. Jociigi laiki pienaakushi programmet saakushi visaadi rahiiti, kas c un vai asm nav redzeejushi un priekshstata par to kaa viss laaciitim veederaa notiek nav nekaada. explode ir tuukstoshiem reizhu leenaaka nekaa $a=$a+1 taatad luuk, explode php funkcijas kods: PHP_FUNCTION(explode) { zval **str, **delim, **zlimit = NULL; int limit = -1; int argc = ZEND_NUM_ARGS(); if (argc < 2 || argc > 3 || zend_get_parameters_ex(argc, &delim, &str, &zlimit) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(str); convert_to_string_ex(delim); if (argc > 2) { convert_to_long_ex(zlimit); limit = Z_LVAL_PP(zlimit); } if (! Z_STRLEN_PP(delim)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter"); RETURN_FALSE; } array_init(return_value); if (! Z_STRLEN_PP(str)) { if (limit >= 0 || argc == 2) { add_next_index_stringl(return_value, "", sizeof("") - 1, 1); } return; } if (limit == 0 || limit == 1) { add_index_stringl(return_value, 0, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1); } else if (limit < 0 && argc == 3) { php_explode_negative_limit(*delim, *str, return_value, limit); } else { php_explode(*delim, *str, return_value, limit); } } PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, int limit) { char *p1, *p2, *endp; endp = Z_STRVAL_P(str) + Z_STRLEN_P(str); p1 = Z_STRVAL_P(str); p2 = php_memnstr(Z_STRVAL_P(str), Z_STRVAL_P(delim), Z_STRLEN_P(delim), endp); if (p2 == NULL) { add_next_index_stringl(return_value, p1, Z_STRLEN_P(str), 1); } else { do { add_next_index_stringl(return_value, p1, p2 - p1, 1); p1 = p2 + Z_STRLEN_P(delim); } while ((p2 = php_memnstr(p1, Z_STRVAL_P(delim), Z_STRLEN_P(delim), endp)) != NULL && (limit == -1 || --limit > 1)); if (p1 <= endp) add_next_index_stringl(return_value, p1, endp-p1, 1); } } PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_value, int limit) { #define EXPLODE_ALLOC_STEP 50 char *p1, *p2, *endp; int allocated = EXPLODE_ALLOC_STEP, found = 0, i = 0, to_return = 0; char **positions = safe_emalloc(allocated, sizeof(char *), 0); endp = Z_STRVAL_P(str) + Z_STRLEN_P(str); p1 = Z_STRVAL_P(str); p2 = php_memnstr(Z_STRVAL_P(str), Z_STRVAL_P(delim), Z_STRLEN_P(delim), endp); if (p2 == NULL) { /* do nothing since limit <= -1, thus if only one chunk - 1 + (limit) <= 0 by doing nothing we return empty array */ } else { positions[found++] = p1; do { if (found >= allocated) { allocated = found + EXPLODE_ALLOC_STEP;/* make sure we have enough memory */ positions = erealloc(positions, allocated*sizeof(char *)); } positions[found++] = p1 = p2 + Z_STRLEN_P(delim); } while ((p2 = php_memnstr(p1, Z_STRVAL_P(delim), Z_STRLEN_P(delim), endp)) != NULL); to_return = limit + found; /* limit is at least -1 therefore no need of bounds checking : i will be always less than found */ for (i = 0;i < to_return;i++) { /* this checks also for to_return > 0 */ add_next_index_stringl(return_value, positions, (positions[i+1] - Z_STRLEN_P(delim)) - positions, 1 ); } } efree(positions); #undef EXPLODE_ALLOC_STEP } Un tagad saliidzini visu sho blaakji ar vienu inkrementa operaaciju: a++;
  4. besis

    Phalcon PHP

    es tos nesaliidzinu, vienkaarshi, tendence ir panaakt PHP aatrdarbiibu ar citaam - progresiivaakaam metodeem, neizmantojot piesieshanos custom extensioniem. c extension manupraat ir dead end prieksh mainstream appiem, tachu vareetu buut labs risinaajums specifiskaas virtuvees.
  5. regexp nav vienkaarshi leeni tie ir Uber leeni, praatiigi cilveeki tos izmanto tikai tur kur citu alternatiivu nav. Protams ja izstraadaataajs razho app kuraa darbosies tikai vinja vecmaaminja tad taada pieeja ir pat vairaak kaa OK. Bet ja tas ir nopietns freimworks vai apps tipa facebook tad tas ir nepiedodami.
  6. tie kas izmanto regexp korē, patieshaam ir stulbi
  7. regexp bremzi baazt korē ir augstākā mērā stulbi, tas pats attiecas uz explodi(protams daudz mazākā mērā nekā regexp). Ja nav elegantaaku risinājumu, tad labāk ir tā kā jau ir uztaisīts.
  8. besis

    Phalcon PHP

    pilniigi lieki. jo ir php-fpm & apc
×
×
  • Create New...